I'm guessing that is done to prevent overflow.
So you need to use your own implementation.
Here are the promote rules defining this behavior: 
So in theory you could also implement your own Int type, that has a 
different promote behavior. Probably not worth it, though ;)

Am Montag, 17. Oktober 2016 15:19:51 UTC+2 schrieb Ángel de Vicente:
> Hi, 
> probably a very basic question, but I'm just starting to play around 
> with Julia types. 
> I was hoping to improve the performance of a little program I wrote, so 
> I decided to try Int32 integers instead of the default Int64, but if I 
> try to use sum, it seems that it is expecting Int64 and the result is 
> Int64, defeating the purpose of working with Int32 and actually making 
> the code much slower than the naive version. 
> ,---- 
> | julia> typeof(sum([i for i in Int32(1):Int32(100)]))                     
>                                                            | 
> | Int64 
> `---- 
> Do I have to write down my own Int32::sum function? I assume I'm missing 
> something quite obvious? 
> Thanks, 
> -- 
> Ángel de Vicente 
> http://www.iac.es/galeria/angelv/           

Reply via email to