• Jeff R. Allen's avatar
    math/rand: Float32/64 must only return values in [0,1) · 17dc712c
    Jeff R. Allen authored
    Float32 and Float64 are now both created by taking the ratio
    of two integers which are chosen to fit entirely into the
    precision of the desired float type. The previous code
    could cast a Float64 with more than 23 bits of ".99999"
    into a Float32 of 1.0, which is not in [0,1).
    
    Float32 went from 15 to 21 ns/op (but is now correct).
    
    Fixes #6721.
    
    R=golang-dev, iant, rsc
    CC=golang-dev
    https://golang.org/cl/22730043
    17dc712c
example_test.go 3.47 KB