JuliaLang/julia — pull request #9387 by rfourquet (2014-12-17 04:47:23+00:00)
Title: fix rand(Float16|Float32) equal to 1

Cf. bug reported by @tkelman in #9301.
As noted by @ivarne, converting a Float64 different from 1 to Float16
or Float32 can produce a value equal to one, which doesn't agree with
the documented API.
So instead of converting, let's produce a Float16/Float32 in [1,2) at
the bit level, and then substract 1 (as was done in the array versions).
As a side effect, this also makes rand(Float16) about twice as fast.