# fixed-point math

I've heard people mention fixed-point math with regards to micro controllers with limited precision. Is there a description of how to implement this on the Arduino?

Thanks,
memotick

Just for example, you could use an int (which can go up to 32767) to hold "tenths" of something, so therefore 20000 in the int could represent 2000.0.

Fixed point math doesn't do tenths very well but it works well on halfs, quarters, eigths, sixteenths plus a few others.

Fixed point math doesn't do tenths very well but it works well on halfs, quarters, eigths, sixteenths plus a few others

do you have a reference for that?

imho there are multiple differenet FPM models,

1. integer FPM ("nicks" model)
2. binary FPM where a bit pattern is representing whole and decimal part (like the DS18B20 uses)
3. BCD format (does not use every possible bitpattern)
4. probably there are others too

memotick:
I’ve heard people mention fixed-point math with regards to micro controllers with limited precision. Is there a description of how to implement this on the Arduino?

Perhaps we should ask the objective here. Is it to get more precision? More speed? Save space?

More speed

This is starting to sound like one of these projects where very detailed questions are being asked, with no description of the overall intention. Perhaps if you describe a bit more what you are attempting? There are lots of ways of saving time, for example using bytes instead of ints, or ints instead of longs.

Fair enough. I am working on an FFT (fast Fourier Transform) using Arduino. This is a complex algorithm and I have read many times that using fixed point rather than floating point numbers helps greatly in the speed of the processing.

I’m planning on doing between 64-256 point FFTs (depending on the results and clock speeds).

Hope that helps, if not please let me know what information would.

Thanks,
memotick

Why reinvent the wheel?
This appears to do 16-bit fixed point.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286718155
and if you need floating point try this one: