News for hackers. Stuff that matters.
Re:How to pack ternary numbers in 8-bit bytes by thechao on Thursday December 05, 2024 @12:06PM (#42330095)
Ternary is a thing; however, there's a lot of times when you're hand-rolling a compression scheme. In those cases, it is common to consider all sorts of nonstandard bases. So, for instance, if you need to encode a pair of numbers, and that pair is in the (rectangular) range: `[0,2]*[0,4]`, then it can be efficiently encoded in a 4b value, using the generalized version of the technique outlined in the article. I know that a lot of GPU block textures rely pretty heavily on products-of-weird-bases, usually 3, 5, and 7. Here's some 'good' combinations (high utilization rates, easy to decode):

3^5 ~ 8b

5^3 ~ 7b

2 * 5 * 7^2 ~ 9b

2 * 3 * 5 ~ 5b

11 * 11 ~ 7b

3 * 5 * 7 ~ 7b

etc.

Re:How to pack ternary numbers in 8-bit bytes by taeric on Thursday December 05, 2024 @12:11PM (#42330144)
Yeah, I was making the mistake of thinking this was storing ternary in a BCD like scheme. I... honestly don't know how I talked myself into that.
Re:How to pack ternary numbers in 8-bit bytes by hinkley on Thursday December 05, 2024 @03:09PM (#42332169)
Doom also famously redefined a circle as 256° and reworked all of their trigonometry and polar coordinate translations to match. And so the smallest increment of angle you could do in the game was around 85 arc minutes.
Re:How to pack ternary numbers in 8-bit bytes by kristianp on Friday December 06, 2024 @05:41AM (#42338451)
> famously redefined a circle as 256°

Famously? Where can I read about Doom's odd trigonometry?

Re:How to pack ternary numbers in 8-bit bytes by kristianp on Friday December 06, 2024 @06:15AM (#42338682)