• Robert Griesemer's avatar
    math/big: wrap Float.Cmp result in struct to prevent wrong use · 23fd374b
    Robert Griesemer authored
    Float.Cmp used to return a value < 0, 0, or > 0 depending on how
    arguments x, y compared against each other. With the possibility
    of NaNs, the result was changed into an Accuracy (to include Undef).
    Consequently, Float.Cmp results could still be compared for (in-)
    equality with 0, but comparing if < 0 or > 0 would provide the
    wrong answer w/o any obvious notice by the compiler.
    
    This change wraps Float.Cmp results into a struct and accessors
    are used to access the desired result. This prevents incorrect
    use.
    
    Change-Id: I34e6a6c1859251ec99b5cf953e82542025ace56f
    Reviewed-on: https://go-review.googlesource.com/7526Reviewed-by: 's avatarRob Pike <r@golang.org>
    23fd374b
float.go 36.6 KB