I can see why this is -- the dimensions of the array we want to create must be an integer, but 1e6 is a float.
This can be a little inconvenient when working with larger numbers however. rand(1000000)
is not particularly tidy. Especially if we need to often need to create many large random arrays.
I was thinking maybe we could use multiple dispatch to accept some floats?
Perhaps something a bit like:
function rand(floatValue::Float64)
integerValue = convert(Int, floatValue)
rand(integerValue)
end
This converts the supplied float to an integer and then calls the OG rand on the new int.
It also conveniently stops people from trying, say, rand(2.3)
by throwing an InexactError.
No we'll not add back using floating points as integers. I don't see how is 1000000
not tidy and there are many other options if you want to make counting easier/typing shorter like 1_000_000
or 10^6
or just do the convertion yourself Int(1e6)
.
Most helpful comment
No we'll not add back using floating points as integers. I don't see how is
1000000
not tidy and there are many other options if you want to make counting easier/typing shorter like1_000_000
or10^6
or just do the convertion yourselfInt(1e6)
.