Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site turtlevax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!turtlevax!ken From: ken@turtlevax.UUCP (Ken Turkowski) Newsgroups: net.lang.c Subject: How to test for +/- INFINITY, etc. in C with IEEE Message-ID: <993@turtlevax.UUCP> Date: Tue, 10-Dec-85 23:46:27 EST Article-I.D.: turtleva.993 Posted: Tue Dec 10 23:46:27 1985 Date-Received: Fri, 13-Dec-85 08:06:03 EST Organization: CIMLINC, Inc. @ Menlo Park, CA Lines: 26 Keywords: conversions are a pain in casts Summary: 0x1050 is a bit pattern, not an integer I would like to be able to test for INFINITY, NaN, and other such things within C. Now, if I try to cast the value for INFINITY (0x7F800000 in single) to a float, ((float)(0x7F800000)) the C compiler changes it into 0x4EFF0000 which does not compare the same as 0x7F800000. Can anyone recommend a way to quickly compare a float against INFINITY? I can't use a subroutine, because the C compiler changes the float to a double. *STEAM follows* The C compiler should assume that only decimal constants need be converted from integer to floating point. Octal and hexadecimal constants are used to represent bit patterns, not numbers. There is no reason that the compiler should assume that a particular bit pattern represents an integer rather than a floating-point number or something even more exotic. -- Ken Turkowski @ CIMLINC, Menlo Park, CA UUCP: {amd,decwrl,hplabs,seismo,spar}!turtlevax!ken ARPA: turtlevax!ken@DECWRL.DEC.COM