Page 1 of 1
What's faster float or double on ARM?

Posted:
Feb 19, 2004 @ 4:23pm
by kornalius
I'd like to know what type is faster: float or double on the ARM? My compiler uses double at this point but I'd like to speed it up a bit more by using float. Will I see a good gain?
I would also like to know if float type is enough for a compiler/interpreter use or I absolutely have to use double type variables?
Btw, my compiler uses no variable types at all. The internal of course do but the user doesn't know about it.
Regards,
Kornalius

Posted:
Feb 19, 2004 @ 5:14pm
by Presto
I don't think you'll see any gain. Without a floating point processor, any use of float or double is going to be a bit slow. Personally, I prefer using doubles rather than floats, simply because a lot of the functions are designed for doubles (sqrt for example), and the time it would take to typecast the double results to a float would probably negate any potential gain of using the float.
That's just my take on it. I know there are a lot of people here into using fixed-point math. I try to avoid floats/doubles whenever possible, but when I do need that precision, I'm using doubles.
-John

Posted:
Feb 19, 2004 @ 5:31pm
by angedelamort
float are 4 bytes and double 8 bytes. So the float should be faster and takes less memory. But less precision (but it's enouph).
I have made a floating point emulation class for Brew and if the ppc do the same thing, it should be faster with just float.
And for your information... I don't think casting float to double takes that much times when you call sqrt. You should avoid sqrt instead...

Posted:
Feb 19, 2004 @ 9:42pm
by mlepage
Make a typedef so you can test between the two. That's good practice anyways because the answer may change from compiler to compiler, or on different devices with various hardware or libraries.
I personally found in one project that float was a bit faster than double. But your project could be different! There are various tradeoffs, and your project may favour some more than others (such as my project).

Posted:
Feb 19, 2004 @ 11:14pm
by kornalius

Posted:
Feb 23, 2004 @ 12:14pm
by refractor
On ARMs it really depends what internal format the floating point emulator (FPE) is using. I know that some use double as their internal format, so crunching a lot of floats incurs a lot of translations to/from double on the way in/out of the FPE. That generally means that floats may be processed slower than doubles.
Really, I concur with mlepage; it depends on what you're doing. Benchmark benchmark benchmark..