Sign in to follow this  

floating point calculation in mobile so slow

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

If you intended to correct an error in the post then please contact us.

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:
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.

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

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

If you intended to correct an error in the post then please contact us.

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