Runtime speed integer versus double

Dear fellow programmers,

Is using integers faster than using floating points? Or more precise: what do you estimate as the chance that writing a custom floating point class is worth the effort?

I need to examine some C++ code for an ARM7 or ARM9 processor. Instead of using floating points, the coder had chosen to use integers only. To be able to fake floating points, a custom class was written. The coder states that he avoids using floating points as these are much how much slower. "Have you measured this?", I asked. "No, but it is known to be so", he replied.

Google taught me that most people state integers are faster than using doubles, because their operations (addition, multiplication) take less assembler instructions. But if you need those floating points, what do you estimate as the chance that writing a custom floating point class is worth the effort?

Thanks, Bilderbikkel
custom floating point class is worth the effort?
No

Fixed point class probably will: for example it is more profitable to store money as integer cents (1250) as opposed to fraction dollars (12.5)

though floating point multiplication is somewhat slower (up to 5 times), it will not make any difference in your program if you don't only do simple arithmetic operations. So in most cases loss of precision in FP values creates more problems than it's speed.

http://stackoverflow.com/questions/5069489/performance-of-built-in-types-char-vs-short-vs-int-vs-float-vs-double
MiiNiPaa,

Thanks for the reference!

I posted my conclusions (and thanks to you) here:

http://www.richelbilderbeek.nl/CppReplaceDoubleByCustomClassUsingIntegers.htm

Cheers, Bilderbikkel
Topic archived. No new replies allowed.