Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.


#1 2021-04-01 02:06:28

Registered: 2021-02-18
Posts: 27

8.8 Fixed-Point Numbers (signed) with GBDK2020

For those interested I ported 8.8 Fixed-Point Numbers (signed) using GBDK2020: … 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'

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.

There are a couple of "helper" functions included:
- Absolute Value
- Fixed Point Multiplication
- Fixed Point Division
- Fixed Point Module
- Fixed Point to String

Last edited by M2m (2021-04-01 02:22:28)



Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson