This may be a candidate for stupidest question of the year, but I am new to 3D and graphics cards...
But like the title says, why does Irrlicht use floats instead of doubles?
Why does Irrlicht use floats instead of doubles?
-
- Posts: 36
- Joined: Sat Feb 06, 2010 11:52 am
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
"Floats and doubles both hold decimal numbers but the difference comes from what precision of numbers they can hold.
For example, a float can normally hold numbers that are roughly 7 digits long (3.141592) but doubles can normally hold numbers that are about 15 digits (3.14159265358979). That's a lot more precision!
The name "double" comes from the fact that in the computer, doubles take twice as much memory than floats."
I hope this answers your question- it`s a typical quality-vs-performance decision. It is assumed, that a float will be precise enough for most of the cases. If you need better precision, you`ll use double for the cost of memory.
For example, a float can normally hold numbers that are roughly 7 digits long (3.141592) but doubles can normally hold numbers that are about 15 digits (3.14159265358979). That's a lot more precision!
The name "double" comes from the fact that in the computer, doubles take twice as much memory than floats."
I hope this answers your question- it`s a typical quality-vs-performance decision. It is assumed, that a float will be precise enough for most of the cases. If you need better precision, you`ll use double for the cost of memory.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Posts: 36
- Joined: Sat Feb 06, 2010 11:52 am
Thanks Shadowslair, but I was always under the impression that C++ converts floats to doubles before all calculations, then back again afterwards, which would be a slowdown. Are there other factors that compensate for this?
In terms of memory usage, does the difference actually mean anything nowadays? Is taking up extra memory going to slow it down? What's the lowest common denominator target that is affected?
I'm just interested as to the background behind the reasoning, to help improve my understanding of this area. Thanks for any hints you can give!
In terms of memory usage, does the difference actually mean anything nowadays? Is taking up extra memory going to slow it down? What's the lowest common denominator target that is affected?
I'm just interested as to the background behind the reasoning, to help improve my understanding of this area. Thanks for any hints you can give!
-
- Posts: 36
- Joined: Sat Feb 06, 2010 11:52 am
Older cpus used the 80-bit FPU, but newer ones use the SSE unit which has 4 32-bit pipelines.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net