Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!seismo!rochester!cornell!batcomputer!braner From: braner@batcomputer.UUCP Newsgroups: comp.lang.c Subject: Re: fabs(x) vs. (x) < 0 ? -(x) : (x) Message-ID: <160@batcomputer.tn.cornell.edu> Date: Wed, 11-Feb-87 01:32:46 EST Article-I.D.: batcompu.160 Posted: Wed Feb 11 01:32:46 1987 Date-Received: Thu, 12-Feb-87 04:06:03 EST References: <4943@mimsy.UUCP> <2550005@hpisod2.HP> <756@unc.unc.UUCP> <2181@batcomputer.tn.cornell.edu> <1315@ho95e.ATT.COM> Reply-To: braner@batcomputer.UUCP (braner) Distribution: na Organization: Theory Center, Cornell University, Ithaca NY Lines: 21 Summary: bit-clearing via #define: wrong [] eeexcuse me, but: #define fabs(x) ((x) & 0x7FFFFF...) will NOT work, and for several reasons: The two operands ((x) and 0x7F...) are not of the same type, so one of them has to be converted. Then it won't work!! Actually, it is illegal to do '&' on a real, if I remember right. And also, doubles are usually longer than longs (until we get 64-bit longs :-). You MIGHT get away with ((*(long *)&x) & 0x7FFFFFFF), but only in cases where &x is legal, and only on machines where the sign bit of x is where you expect it... - Moshe Braner THE COMPLETE FP LIB MUST BE WRITTEN IN HAND-OPTIMIZED AL!!! ESPECIALLY SO IF YOU HAVE FP HARDWARE!!!