Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If your language has bad defaults, you may have to ask for the right rounding mode explicitly.

Is the author implying Rust's default rounding behavior is a bad default? In what world is "ties to even" a GOOD default?



It's also called banker's rounding. To understand why it's a good default, you can check out https://mathematica.stackexchange.com/a/2120


The motivation for the seemingly strange rounding is that a set of numbers can be rounded before summing without biasing the sum. It has good use cases but so do all rounding modes.


In general, if some recommendation from IEEE 754 (the floating-point standard) seems strange, its because someone like William Kahan thought about it in great detail and you'd be wise to follow it.

https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: