Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2005-11-17 18:31:49

"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.


Boost list run by bdawes at, gregod at, cpdaniel at, john at