Skip to content

zeros(1e4) -> ERROR: no method Array(DataType,Float64) #4275

@Staross

Description

@Staross

I find this a bit annoying, because I'm used to use the exponent notation to declare large numbers. Of course I could do zeros(10^4) but I think it should also work with 1e4.

The problem is that 1e4 is a float and 10^4 an int, and that Array doesn't accept floats for dimensional arguments.

Is there any problems with trying to convert floats to int when declaring arrays ? I think it would simplify things quite a bit, and it seems safe to me, since convert will give an InexactError when trying to declare an array with 10.5 elements.

It would also solve this kind of weird behavior:

julia> zeros(100/10)
ERROR: no method Array(DataType,Float64)
 in zeros at array.jl:205

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions