1
Network / Safest way to send floats over sockets?
« on: April 12, 2009, 05:35:52 pm »
The SFML packet tutorial mentions problems that can arise from exchanging primitive types over sockets to different platforms. As a solution, it mentions
What is the safest way to avoid problems while sending floats (and doubles) over a socket? Does the IEEE floating point standard define floats to be 32-bits and doubles to be 64-bits? If so, are there any platforms that deviate from the standard that I (well, I suppose everyone) should be aware of?
Quote
... to use SFML's fixed size types : sf::Int8, sf::Uint16, sf::Int32, etc. Those types are guaranteed to have the intended size on any platform.
What is the safest way to avoid problems while sending floats (and doubles) over a socket? Does the IEEE floating point standard define floats to be 32-bits and doubles to be 64-bits? If so, are there any platforms that deviate from the standard that I (well, I suppose everyone) should be aware of?