-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
IEEE 754-2008 specifies 5 rounding-direction attributes with 4 implemented by the math package:
roundTiesToEven:RoundTiesToEven(proposed) (wasRint)roundTiesToAway:RoundroundTowardPositive:CeilroundTowardNegative:FloorroundTowardZero:Trunc
No other rounding-attributes are specified by IEEE 754. There have been various proposals in the past requesting highly configurable esoteric rounding modes beyond IEEE. I don't believe they should be considered for the math package.
I'd suggest using the following signature: func RoundTiesToEven(float64) float64
Most people generally prefer TiesToAway for common usage (hence #20100). However TiesToEven has statistical properties that are preferable for some applications. Implementations of IEEE 754 are required to provide TiesToEven.
For comparison, other languages provide support for TiesToEven:
- C99:
rint - Java:
Math.rint - Python v3 (not v2):
round
Pro:
- Statistically useful for some applications.
- Easy to implement incorrectly with many subtle edge-cases. A reliable stdlib implementation prevents bugs.
- Required for IEEE 754. It's the only mode not supported by the math package and would complete IEEE rounding support.
- math package is the most appropriate location for TiesToEven support since all the other modes are in math.
Con:
- +1 function to math package API.
jimmyfrasche, a-h and ericlagergren
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.