Sign in to follow this  

floating point calculation in mobile so slow

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 this post

Link to post
Share on other sites
You can try to port this one:
Also check out the Allegro lib, they provide a fixed point implementation:

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.

- addition/subtraction remains the same
- 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

There are different division algorithms, also available in the wiki:

Share this post

Link to post
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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this