You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Random#rand method with Range(Float, Float) overload is returning Float64, which makes it impossible to use it with Range(Float32, Float32) argument.
random = Random.new
random.rand(1..10) # ok
random.rand(1u8..10u8) # ok
random.rand(1.0..10.0) # ok
random.rand(1.0f32..10.0f32) # error: type must be Float64, not Float32
I don't know whether there is a reason, but this overload should probably return Float instead of Float64, as in the case of Range(Int, Int) overload.
Any idea how to work around this, beside casting to Float64 and then back to Float32 after generating random number?
Yeah, it's just the return type is to restrictive, it should be Float not Float64.
Until this is fixed, you can just reopen the class in your code and override the method.
Random#rand method with Range(Float, Float) overload is returning Float64, which makes it impossible to use it with Range(Float32, Float32) argument.
I don't know whether there is a reason, but this overload should probably return Float instead of Float64, as in the case of Range(Int, Int) overload.
Any idea how to work around this, beside casting to Float64 and then back to Float32 after generating random number?
Ubuntu 18.04, Crystal 0.25.1 [b782738] (2018-06-27)
The text was updated successfully, but these errors were encountered: