r/programming • u/fagnerbrack • Jul 05 '26
Floating point from scratch: Hard Mode
https://essenceia.github.io/projects/floating_dragon/
154
Upvotes
r/programming • u/fagnerbrack • Jul 05 '26
View all comments
Show parent comment
2
u/BounceVector Jul 08 '26
Your question was answered well by others, but i f you want to learn more: https://www.altdevarts.com/p/onboarding-floating-point
Also personally I find it helpful to think of floats as a number format that has different "gaps" than everyday decimal numbers. Alternatively You could use BCM (binary coded decimals -> every digit = 1 byte -> wastes memory for every digit) or scaled integers with a fixed point to represent decimal values.
Floats aren't for exact numbers, but for close enough numbers with good precision in a vast range of possible values. They are really flexible! Very often you don't need that flexibility though and people still use them, because ... it's easy and many others do it too. Worse is always better, I guess.