dev.nlited.com

>>

Floating Point

<<<< prev
next >>>>

2016-02-03 17:54:47 chip Page 1554 📢 PUBLIC

Feb 3 2016

I learned to program when floating-point operations were prohibitively expensive and to be avoided whenever possible. In fact, my first real job was focused on optimizing an image compression reference design by replacing all the floating point operations with equivalent integer math. Everything I wrote since has been influenced by this.

The Rocket project has been a great education. Today I converted everything in Rocket to use floating-point, even the screen POINT locations. The performance is no worse, possibly slightly better, than my original version. This makes sense since the all the Direct2D functions take floating-point parameters, forcing me to constantly convert integers to floats, which is just as expensive as any floating-point operation. I am running at 60fps with 5000 sprites, all floating-point all the time.

There is no longer any performance advantage to preferring integers over floats. That isn't to say integers should be abandoned altogether, there are many cases where the logic dictates the use of integers. Just that performance is no longer a reason.



WebV7 (C)2018 nlited | Rendered by tikope in 59.310ms | 18.224.59.138