Re: [julia-users] Re: overflow behavior

2016-04-05 Thread Erik Schnetter
On Tue, Apr 5, 2016 at 10:50 AM, Páll Haraldsson
 wrote:
> On Tuesday, April 5, 2016 at 2:45:38 PM UTC, Didier Verna wrote:
>>
>>
>>   Hello,
>>
>> the manual says: "In Julia, exceeding the maximum representable value of
>> a given type results in a wraparound behavior:", but that seems to be
>> the case only for the native type and above:
>>
>> julia> typeof(typemax(Int64)  + 1) -> Int64
>> julia> typeof(typemax(Int128) + 1) -> Int128
>>
>> but:
>>
>> julia> typeof(typemax(Int8)   + 1) -> Int64
>> julia> typeof(typemax(Int16)  + 1) -> Int64
>> julia> typeof(typemax(Int32)  + 1) -> Int64
>
>
> Right, the manual could be updated, I guess. The last one, gives you Int32
> on 32-bit platforms. This i all intentional. Then there is Int128 and BigInt
> (no modular there).

`Int128` does use modulus semantics.

-erik

>> These last 3 results seem inconsistent (and the manual incorrect)
>> because for example, typeof(typemax(Int8)) -> Int8 and not Int64, so no,
>> Julia doesn't do modular arithmetics all the time.
>>
>> --
>> Resistance is futile. You will be jazzimilated.
>>
>> Lisp, Jazz, Aïkido: http://www.didierverna.info


-- 
Erik Schnetter 
http://www.perimeterinstitute.ca/personal/eschnetter/


Re: [julia-users] Re: overflow behavior

2016-04-05 Thread Didier Verna
Páll Haraldsson  wrote:

> Right, the manual could be updated, I guess. The last one, gives you
> Int32 on 32-bit platforms.

  I expected as much, indeed.

-- 
Resistance is futile. You will be jazzimilated.

Lisp, Jazz, Aïkido: http://www.didierverna.info


[julia-users] Re: overflow behavior

2016-04-05 Thread Páll Haraldsson
On Tuesday, April 5, 2016 at 2:45:38 PM UTC, Didier Verna wrote:
>
>
>   Hello, 
>
> the manual says: "In Julia, exceeding the maximum representable value of 
> a given type results in a wraparound behavior:", but that seems to be 
> the case only for the native type and above: 
>
> julia> typeof(typemax(Int64)  + 1) -> Int64 
> julia> typeof(typemax(Int128) + 1) -> Int128 
>
> but: 
>
> julia> typeof(typemax(Int8)   + 1) -> Int64 
> julia> typeof(typemax(Int16)  + 1) -> Int64 
> julia> typeof(typemax(Int32)  + 1) -> Int64
>

Right, the manual could be updated, I guess. The last one, gives you Int32 
on 32-bit platforms. This i all intentional. Then there is Int128 and 
BigInt (no modular there).

>
> These last 3 results seem inconsistent (and the manual incorrect) 
> because for example, typeof(typemax(Int8)) -> Int8 and not Int64, so no, 
> Julia doesn't do modular arithmetics all the time. 
>
> -- 
> Resistance is futile. You will be jazzimilated. 
>
> Lisp, Jazz, Aïkido: http://www.didierverna.info 
>