
17 Nov
2005
17 Nov
'05
11:31 p.m.
"Robert Ramey" wrote: [ nan, infinite etc ]
BUT - I can't find any "official" to initialize a float/double to any of these values. They seem to be the result of operations and its certainly not obvious that all compilers would be on the same page here.
Note that this same problem arises whenever a float/double is written/read to/from a stream in a way designed to be portable. So it must have come up before. What's the solution here?
unsigned char nan[sizeof(double)]; nan[0] = ... .... double d; memcpy(&d, nan, sizeof(double); I assume the double/floats are by IEEE standard. /Pavel