@rygorous@mastodon.gamedev.place
2025-03-03 18:16 UTC
@amonakov @kenshirriff For usual signed r8, we want to recode 3 input bits (digits)
000 -> 0
001 -> 1
010 -> 2
011 -> 3
100 -> 8 - 4 (!)
101 -> 8 - 3
110 -> 8 - 2
111 -> 8 - 1
notes:
a) the "carry" into the next digit is just the MSB of the current digit in this scheme
b) we only use [-4,3] weights directly, so we have space to absorb an incoming carry of 1.
This also suggests how to do the recoder: you look at 3-bit digits + MSB of next-lower digit to determine factors for partial products.
Replies (1)
-
@rygorous@mastodon.gamedev.place 2025-03-03 18:21
@amonakov @kenshirriff once you throw in that lower-digit MSB, you get the very satisfyingly symmetric actual r8 Modified Booth recoding map: 0000 -> +0 0001 -> +1 0010 -> +1 0011 -> +2 [..] 0110 -> +3 0111 -> +4 1000 -> -4 1001 -> -3 [..] 1110 -> -1 1111 -> -0 note sign (which is useful to have separately) is just MSB of the active digit and this map has mirror symmetry (so you can fold by XORing low 3 bits by MSB.) This does have the 6x = 8x - 2x as the natural way to handle a 110 digit.