Why does Irrlicht use floats instead of doubles?

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
Linkin Puck
Posts: 36
Joined: Sat Feb 06, 2010 11:52 am

Why does Irrlicht use floats instead of doubles?

Post by Linkin Puck »

This may be a candidate for stupidest question of the year, but I am new to 3D and graphics cards... :D

But like the title says, why does Irrlicht use floats instead of doubles?
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

"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. :wink:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Linkin Puck
Posts: 36
Joined: Sat Feb 06, 2010 11:52 am

Post by Linkin Puck »

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!
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

Post by DtD »

Not sure where you heard that, but someone is BSing you ;) Graphics cards natively use floats, and floats are the same bitwidth of every 32-bit CPU. With doubles the CPU has to use more cycles because a double is 64-bit.
Linkin Puck
Posts: 36
Joined: Sat Feb 06, 2010 11:52 am

Post by Linkin Puck »

DtD wrote:Not sure where you heard that, but someone is BSing you
That's quite possible! :D
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

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
Post Reply