← Back to context

Comment by magicalhippo

3 hours ago

> I'm fairly certain that a) IEEE does not mandate the in-memory representation,

That's not how I interpret section 3.2 in the standard[1]. Figure 1 seems quite explicit in how a single and a double should be encoded. The section on extended values specify they can be encoded in an implementation-depended manner, which makes the case stronger IMO.

edit: I note that in the 2008 revision[2], it's more explicitly mentioned that the specified encoding is a binary interchange format. So that's a lot more specific than the original.

[1]: https://pub.sergev.org/doc/ieee754-1985.pdf

[2]: https://pub.sergev.org/doc/ieee754-2008.pdf

It only talks about MSBs and LSBs. It does not specify whether the LSB of the value as the whole resides in the first byte of the memory representation or in the fourth/eighth.

And of course, if you accept the network byte order as the one intended for the interchange, then IEEE-754 mandates big-endian encoding.

  • Maybe you are talking past grandparent, but I think they meant "it's safe to assume float and double are IEEE-754," which is not mandated by the C standard.