Jump to content
  • Advertisement
Sign in to follow this  

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.

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:
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 http://en.wikipedia.org/wiki/Shifting_nth-root_algorithm

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!