In Julia 0.4.0, when I try
rand(AbstractFloat, 1)
The following error is obtained:
ERROR: MethodError: `rand` has no method matching rand(::MersenneTwister,
::Type{AbstractFloat})
Is there a reason behind the fact that I must explicitly say Float32 or Float64 for rand to work? Or is it just that, as the language is relatively new, a relevant method has yet to be defined in the Base?
BigFloat,Float16,Float32andFloat64.one(AbstractFloat)gives either aFloat32orFloat64object depending on the system. Shouldn'trandhave the same behaviour?rand(Float64)does not actually cover the whole range ofFloat64values, but the [0,1) interval unlike theIntfamily, it seems reasonable to define this as an Abstract behavior and extend toAbstractFloat. Good point @Taiki