https://github.com/sttng/gb-stuff/blob/ ... fixed8x8.c
8.8 fixed point numbers use 16bit. Basically there are 8bits for the whole (integer) part of the number, and another 8bit for the fractional (decimal) part. For example in 8.8 fixed point type the number:
2.5 ("two and half"), is encoded as
'2' 'half'
00000010.10000000
Using two's complement encoding for the whole part we get a range from -128 to +127. For the decimal part we have 0.00390625 (1/256) as the tiniest fraction - the range would go up until 0.99609375.
There are a couple of "helper" functions included:
- Absolute Value
- Fixed Point Multiplication
- Fixed Point Division
- Fixed Point Modulo
- Fixed Point to String