We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
In ANSI C, relative to floats and doubles, is the concept of 'not a number' and plus and minus infinity supported by named constants that you can use to test variables with to see if they do contain 'valid' floats and doubles? If not, is there some other topic I could investigate to perform that type of test? Curious, Dave.
ANSI 'C' has MAXINT, MAXFLOAT, MAXDOUBLE, etc - do they help? I think they're in LIMITS.H and/or VALUES.H Dunno about the NaN though - does your FP library provide specific support?
We use the 51/251 tools, and NAN is supported for several float functions directly. There is also a library function _chkfloat_(float) and _chkdouble_(double) that return values describing NAN, +/- INF, float 0, or standard #. Check the compiler manual for details
Thanks. My question actually arose on a different development platform and target. I see the C166 compiler manual references an IEEE standard. I'm really curious whether the referenced constants are a part of ANSI C, or if they're an extension to it that KEIL implemented. Do you know? It appears that the 'test' functions in KEIL's C166 tools must be called to get a status of the validity of value in the float or double variable. Since I don't have the source code to those library functions I'm not sure how they work. Do you know if they do something like typecast the value of the variable in question to something like an unsigned long int and then compare that against the referenced IEEE constants? If so, I should be able to create equivalent functions for my other development environment.