[comp.lang.c] need isnan and isinf src for microsoft c

gene@ponder.csci.unt.edu (Gene De Lisa) (04/23/91)

Could someone tell me how to detect NaN and infinite numbers
in microsoft c? There are functions with SunOS libm.a that
do this but I need to also do it on a Pc.

help please.
-- 
more direct:

vortech!gene@Central.Sun.COM

richard@aiai.ed.ac.uk (Richard Tobin) (04/29/91)

In article <1991Apr22.173940.25021@solo.csci.unt.edu> gene@ponder.csci.unt.edu (Gene De Lisa) writes:
>Could someone tell me how to detect NaN and infinite numbers

Infinities have the exponent set to its maximum value and the mantissa
zero.  NaNs have the same exponent but a non-zero mantissa.

For single precision the format is sign bit, 8 bit exponent, 23 bit mantissa.
For double precision the numbers are 11 and 52.

>in microsoft c?

Assuming it uses IEEE format, as above, but you have to be careful
about byte order.

-- Richard
-- 
Richard Tobin,                       JANET: R.Tobin@uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin