Le jeudi 03 décembre 2015 à 06:36 -0800, Stephan Buchert a écrit :
> julia> Int32[5730]*Int32(86400)
> 1-element Array{Int32,1}:
>  495072000
> 
> should certainly give the in memory smaller Int32 Array (and
> InexactError if applicable). But an Int32 Array times an Int64 scalar
> could well give automatically an Int64 array, I think. Then 
You can argue this as well, in the end it's a judgment call, based in
particular on what kind of scenarios you expect. As Mauro said, the
idea behind the current behavior is that an array of Int32 is not the
default, so if you chose it you must have good reasons, like reducing
memory consumption when storing small numbers.

It's true that it's a bit inconsistent with the fact that Int32 * Int64
gives Int64 (on 64-bit systems).

> julia> Int32[5730]*1
> 
> and similar things could be used to promote arrays (which otherwise 
> seems not that easy in Julia).
At least, this doesn't sound like a good justification. What's wrong
with these solutions?
julia> Array{Int64}(Int32[5730])
1-element Array{Int64,1}:
 5730

julia> convert(Array{Int64}, Int32[5730])
1-element Array{Int64,1}:
 5730

julia> map(Int64, Int32[5730])
1-element Array{Int64,1}:
 5730


Regards

Reply via email to