FPMath: A J2ME fixed-point math libraryMarch 28, 2011 Math
Mobile devices don’t always come with native support for fractional or real numbers and matching math functions. During the development of Razor in 2005, I found myself in need of a small, fast and reliable math library and created FPMath, a 16.16 fixed point math library for the J2ME (Java) platform. This library is now released under the Modified BSD license and can be downloaded freely below.
Fixed point numbers are stored as ints, reserving the upper 16 bit for the signed integer part, and the lower 16 bit for the fractional part divided in 1/65536ths. The following functions are available:
All functions come with doxygen-annotated descriptions, that also include the function’s maximum epsilon error, as found during brute-force exhaustive testing. The library has been optimized thorougly for performance, while requiring only a total of 560 bytes for its lookup tables. Feel free to ask for additional details.