8.8 Fixed-Point Numbers (signed) with GBDK2020

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
M2m
Posts: 15
Joined: Mon Feb 15, 2021 8:31 pm

8.8 Fixed-Point Numbers (signed) with GBDK2020

Post by M2m » Wed Mar 31, 2021 11:02 pm

For those interested I ported 8.8 Fixed-Point Numbers (signed) using GBDK2020:

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

KayBur
Posts: 12
Joined: Mon Mar 29, 2021 6:47 am

Re: 8.8 Fixed-Point Numbers (signed) with GBDK2020

Post by KayBur » Thu Apr 01, 2021 7:30 am

Very interesting. I think it is easier to use the established prescribed values than to calculate them yourself.

M2m
Posts: 15
Joined: Mon Feb 15, 2021 8:31 pm

Re: 8.8 Fixed-Point Numbers (signed) with GBDK2020

Post by M2m » Thu Apr 01, 2021 7:30 pm

KayBur wrote:
Thu Apr 01, 2021 7:30 am
Very interesting. I think it is easier to use the established prescribed values than to calculate them yourself.
What do you mean ? I don't think GBDK2020 has fixed-points included. Or did I miss them ?

calima
Posts: 1329
Joined: Tue Oct 06, 2015 10:16 am

Re: 8.8 Fixed-Point Numbers (signed) with GBDK2020

Post by calima » Thu Apr 01, 2021 11:36 pm

He is a spammer, just ignore them.

nocash
Posts: 1343
Joined: Fri Feb 24, 2012 12:09 pm
Contact:

Re: 8.8 Fixed-Point Numbers (signed) with GBDK2020

Post by nocash » Sat Apr 03, 2021 8:48 am

Or a chat bot child confused about the human obsession with calculating new numbers. There are so many numbers readily available in the internet, what's the point in calculating yet more numbers? Plus, it's difficult to find good numbers for small talk, everybody is happy when you say that you have 1 cat, or 2 cats, but reactions are inexplicably different when you say that you have 15,724 cats.
homepage - patreon - you can think of a bit as a bottle that is either half full or half empty

M2m
Posts: 15
Joined: Mon Feb 15, 2021 8:31 pm

Re: 8.8 Fixed-Point Numbers (signed) with GBDK2020

Post by M2m » Sun Apr 04, 2021 12:59 am

nocash wrote:
Sat Apr 03, 2021 8:48 am
Or a chat bot child confused about the human obsession with calculating new numbers. There are so many numbers readily available in the internet, what's the point in calculating yet more numbers? Plus, it's difficult to find good numbers for small talk, everybody is happy when you say that you have 1 cat, or 2 cats, but reactions are inexplicably different when you say that you have 15,724 cats.
On the Gameboy I think fixed cats are better then floating cats :D - at least faster !

User avatar
Quietust
Posts: 1713
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: 8.8 Fixed-Point Numbers (signed) with GBDK2020

Post by Quietust » Sun Apr 04, 2021 6:04 am

M2m wrote:
Sun Apr 04, 2021 12:59 am
On the Gameboy I think fixed cats are better then floating cats :D - at least faster !
But floating cats are more amusing, and much easier to transform into lolcats.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

nocash
Posts: 1343
Joined: Fri Feb 24, 2012 12:09 pm
Contact:

Re: 8.8 Fixed-Point Numbers (signed) with GBDK2020

Post by nocash » Sun Apr 04, 2021 7:41 am

That is so cruel, cats really hate floating!
M2m wrote:
Sun Apr 04, 2021 12:59 am
On the Gameboy I think fixed cats are better
Uhm, yes, that's common practice, dunno about making a gameboy title about it though?
homepage - patreon - you can think of a bit as a bottle that is either half full or half empty

M2m
Posts: 15
Joined: Mon Feb 15, 2021 8:31 pm

Re: 8.8 Fixed-Point Numbers (signed) with GBDK2020

Post by M2m » Sun Apr 04, 2021 10:00 am

nocash wrote:
Sun Apr 04, 2021 7:41 am
That is so cruel, cats really hate floating!
M2m wrote:
Sun Apr 04, 2021 12:59 am
On the Gameboy I think fixed cats are better
Uhm, yes, that's common practice, dunno about making a gameboy title about it though?
https://www.youtube.com/watch?v=KgrrDavNT30

Post Reply