Repeating of course
(midwest.social)
(midwest.social)
I had to just emulate floating points to save pulling in the giant print float library in stm32 to save flash memory. And then I learned that's what all the pros do IRL anyway.
I feel obligated to post a link to this excellent (albeit incomplete) writeup of posits and unums, which can more accurately represent common fractions in memory at the same (or lower) bit size compared to traditional floating point.
Said page also includes the single best slightly-above-entry-level explanation of how floating point works I've ever seen.
i have so many protocols to represent the most common fractions perfectly without needing more than just ONE bit. They even work with positive and negative infinity!
The trick is to first negotiate the protocol youre using.
protocol schema 1/2
1 bit, little endian
if one: value is exactly 1/2
If zero: value is NOT one half
Schema 1/3
if one: value is 1/3
I've managed to create a compression algorithm that reduces files down to a single bit. I call it "is this file 'loss.png'?".
It's guaranteed 100% lossless with any input!
But... they are fractions.
They are fractions of the format m/(2^n), but they only mimic fractions like 2/5.
I guess op refers to how they're represented which is a bit complex imo: https://www.geeksforgeeks.org/digital-logic/floating-point-representation-basics/
If you need actual numerators and denominators, there are libraries for that.
Ah, Apache Commons: for those who felt Java's standard library wasn't bloated enough already.
(I kid, I kid, though it was always funny just how many basic features seemed to be missing from Java back in the day despite its massive bundled library, leading to seemingly every major project adding Commons as a dependency. Not as much as thing these days AFAIK)

Matrix chat room: https://matrix.to/#/#midwestsociallemmy:matrix.org
Communities from our friends:
LiberaPay link: https://liberapay.com/seahorse