Hacker News new | ask | show | jobs
by filoeleven 999 days 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.

1 comments

Yeah, I thought about that. Wonder how efficiently a database can be tweaked to support this, cause that might matter even more than language support.