Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
General
»
Cross Platform float
Print
Pages: [
1
]
Author
Topic: Cross Platform float (Read 2427 times)
0 Members and 1 Guest are viewing this topic.
Foaly
Sr. Member
Posts: 453
Cross Platform float
«
on:
June 12, 2012, 01:17:46 pm »
In config.hpp SFML defines a bunch of fixed-point data types in a cross-platform way (sf::Int16 etc.). I was wondering why are there no floating point data types (i.e. float or double)? I read somewhere that they are not consistent across all platforms either.
Logged
Laurent
Administrator
Hero Member
Posts: 32504
Re: Cross Platform float
«
Reply #1 on:
June 12, 2012, 02:00:07 pm »
The C++ standard doesn't define a specific encoding for floating point numbers, but on all the platforms that SFML supports you can expect floats to use the IEEE-754 representation with fixed sizes.
Logged
Laurent Gomila - SFML developer
Foaly
Sr. Member
Posts: 453
Re: Cross Platform float
«
Reply #2 on:
June 12, 2012, 03:50:29 pm »
Meaing on windows, Mac and Linux float and double will always be the same size?
Logged
Laurent
Administrator
Hero Member
Posts: 32504
Re: Cross Platform float
«
Reply #3 on:
June 12, 2012, 04:02:50 pm »
Yes.
Logged
Laurent Gomila - SFML developer
Foaly
Sr. Member
Posts: 453
Re: Cross Platform float
«
Reply #4 on:
June 12, 2012, 06:16:22 pm »
sweet thank you very much!
Logged
MorleyDev
Full Member
Posts: 219
"It is not enough for code to work."
Re: Cross Platform float
«
Reply #5 on:
June 12, 2012, 06:25:41 pm »
I feel the need to note that
long double
will vary from compiler to compiler. On Visual Studio it's no different from a double (8 bytes in size), whilst on gcc it's typically 12 bytes (float is 4 and double is 8 ).
Logged
UnitTest11
- A unit testing library in C++ written to take advantage of C++11.
All code is guilty until proven innocent, unworthy until tested, and pointless without singular and well-defined purpose.
Mario
SFML Team
Hero Member
Posts: 879
Re: Cross Platform float
«
Reply #6 on:
June 14, 2012, 11:11:36 am »
Also keep in mind that there might be different precision/rounding if you're using floats for anything that should stay in sync between platforms.
Logged
Print
Pages: [
1
]
SFML community forums
»
Help
»
General
»
Cross Platform float
anything