# floating point calculation in mobile so slow

This topic is 4515 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

my peers told me to use fixed point arithmetic in substitute to floating point since our device doesnt support float, but i cant find any free libraries on the net that implements fixed point in ANSI C, can u guys help me with this one. perhaps share your fixed point library :) just the basic operations like addition,sub,mult and div., i dont have time to read articles and code it myself since deadline for this module is on wed :(

##### Share on other sites
You can try to port this one:
http://libtomcrypt.bytemine.net/libtomcrypt.org_80/tfm/index.html
Also check out the Allegro lib, they provide a fixed point implementation:
http://alleg.sourceforge.net/onlinedocs/en/alleg032.html

Or you can roll your own. It's not that difficult. Some hints:

Assume that:
x = a * 2^n
y = b * 2^n
z = c * 2^n
where a, b and c are the real values, x, y and z are fixed point values, n is the number of bits behind the dot.

- multiplication: c = a * b, so z = x * y * 2^-n
- division: c = a / b, so z = x * 2^n / y
- square root: read the wiki http://en.wikipedia.org/wiki/Shifting_nth-root_algorithm

There are different division algorithms, also available in the wiki:
http://en.wikipedia.org/wiki/Division_%28electronics%29

##### Share on other sites
If you are usiing ARM CPU you also should get rid of divisions. ARM (9 and 10 IIRC) don't support division and emulate it. Use lookup tables instead.

1. 1
Rutin
19
2. 2
3. 3
JoeJ
15
4. 4
5. 5

• 21
• 19
• 11
• 13
• 17
• ### Forum Statistics

• Total Topics
631697
• Total Posts
3001764
×