> Does C99 or any other C mandate the actual memory layout > of floats and doubles or the exact conversion of constant > representations? > I'm fairly sure they somehow mandate IEEE 754 properties, > but do they actually say that floats and doubles have to be stored > exactly that way in 4 or 8 bytes? > > Even if we assume sizeof(double) == 8, > what if my implementation is perverse and interleaves the exponent > bits amongst the mantissa bits? > Where is this disallowed in the standard(s)?
It doesn't matter what the standard says; it matters what implementations do. C implementations are going to provide what the underlying hardware does, and almost all hardware does IEEE 754. > as long as the conversion you're after has an exact ieee representation, > i can't see how two compliant implementations could come up with > differing representations. (two different numbers can't have the same > ieee representation, except -0 and +0.) the conversion process doesn't > need any floating point itself and the only interpolation comes when > numbers don't have exact representations. Historically, it has not always been true that decimal <-> binary conversion of doubles has been precise enough to replicate a specific bit pattern. While conversion doesn't require floating point, it is often done in floating point anyway for convenience. Russ
