4 ms·
Some languages do have proper support for ratios, so if you define x = 22/14, the value stored is 11/7. Multiply later by 7 and you get 11. You can maintain ex
by filoeleven 3y ago
Some languages do have proper support for ratios, so if you define x = 22/14, the value stored is 11/7. Multiply later by 7 and you get 11.
You can maintain exact calculations through an entire data pipeline this way, as long as your base numbers are all integers and ratios, and optionally have one rounding step at the end if you want a decimal value. Most math languages and lisps do this.
There must be libraries for other languages that can do it too, but it’s much nicer to work with when it’s built-in.
- hot_gril 3y agoYeah, I thought about that. Wonder how efficiently a database can be tweaked to support this, cause that might matter even more than language support.
- yencabulator 3y agoKnown to gophers as a "big rat": https://pkg.go.dev/math/big#Rat https://pkg.go.dev/math/big#Rat