Floating point Endianness?

前端 未结 3 1959
醉梦人生
醉梦人生 2020-12-01 13:41

I\'m writing a client and a server for a realtime offshore simulator, and, as I have to send a lot of data through a socket, I\'m using binary data to maximize the ammount o

相关标签:
3条回答
  • 2020-12-01 14:23

    EDIT: THE FOLLOWING IS WRONG ANSWER (leaving so that people know that this 'somewhat popular' view is wrong, please read the accepted answer and comments on this answer)

    --WRONG ANSWER BEGIN--

    There is no such thing as floating point endianness or integer endianness etc. Its just binary representation endianness. Either a machine is little-endian, or its big-endian. Which means that it will either represent the MSb/MSB in the binary representation of any datatype as its first bit/byte or last bit/byte. Thats it.

    --WRONG ANSWER END---

    0 讨论(0)
  • 2020-12-01 14:26

    Yes, floating point can be endianess dependent. See Converting float values from big endian to little endian for info, be sure to read the comments.

    0 讨论(0)
  • According to Wikipedia,

    Floating-point and endianness

    On some machines, while integers were represented in little-endian form, floating point numbers were represented in big-endian form. Because there are many floating point formats, and a lack of a standard "network" representation, no standard for transferring floating point values has been made. This means that floating point data written on one machine may not be readable on another, and this is the case even if both use IEEE 754 floating point arithmetic since the endianness of the memory representation is not part of the IEEE specification.

    0 讨论(0)
提交回复
热议问题