Get the latest tech news
How to Correctly Sum Up Numbers
When you learn programming, one of the first things every book and course teaches is how to add two numbers. So, developers working with large data probably don't have to think too much about adding numbers, right? Turns out it's not quite so simple!
For floating point operations, the Rust compiler guarantees compatibility with IEEEÂ 754 which means that generally overflows lead to infinity values and underflows are converted to zero. Throwing errors in these cases makes it easier to use the system: instead of returning potentially meaningless results, the query engine lets the user know that they aren’t using the functions in a way that’s safe. Not only does this make overflows much less likely (or even impossible with 128-bit integers), larger intermediate results also allow for better precision when calculating some aggregation functions, such as avg().
Or read this on Hacker News