SFML community forums
Help => Network => Topic started by: osadijfj43 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
... 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?
-
The only rule is sizeof(float) <= sizeof(double) <= sizeof(long double), I think.
But you can build your own type to "patch" this lack with two sf::Int*. Or maybe with another lib (boost ?).
-
There is no standard specification about the size of floating numbers. However, as far as I know, every "common" platform implements them the same way, it's pretty safe to use them directly.
-
I would do like Hiura said if you have to be 100% it's right. We actually did a similar thing in class. We had a struct with two integer to represent a floating point number. How does that sound?