I opened an issue for discussing this topic on Github.

https://github.com/JuliaLang/julia/issues/5796

Ivar

kl. 17:39:01 UTC+1 onsdag 12. februar 2014 skrev Stefan Karpinski følgende:
>
> Another option would be to raise an error if you take the absolute value 
> of typemin(Int).
>
>
> On Wed, Feb 12, 2014 at 11:29 AM, Eric Davies <[email protected]<javascript:>
> > wrote:
>
>> Ah, alright. I wasn't sure what the situation was on 32-bit platforms.
>>
>>
>> On Wednesday, 12 February 2014 10:22:10 UTC-6, Stefan Karpinski wrote:
>>
>>> This is not a bug, it's by design: http://docs.julialang.
>>> org/en/latest/manual/faq/#why-does-julia-use-native-machine-
>>> integer-arithmetic.
>>>
>>>
>>> On Wed, Feb 12, 2014 at 11:20 AM, Eric Davies <[email protected]> wrote:
>>>
>>>> Those on 64-bit systems can replicate this bug with abs(2^63) or 
>>>> abs(-9223372036854775808).
>>>>
>>>> The issue here is that the number 2^31 overflows the Int32 type to 
>>>> -(2^31). The fact that it returns itself is somewhat coincidental.
>>>>
>>>> This is probably a bug, but there are sometimes reasons for allowing 
>>>> overflow.
>>>>
>>>> On Wednesday, 12 February 2014 09:56:15 UTC-6, MikeEI wrote:
>>>>>
>>>>> abs(-2147483648) results in -2147483648 ???
>>>>>
>>>>> @which(abs(-2147483648)) results in
>>>>> abs(x::Signed) at intfuncs.jl:29
>>>>>
>>>>> Shouldn't the type system promote to Int64 as there is no 
>>>>> corresponding Int32 value or indicate error?
>>>>>
>>>>> Just a newcomers/learners question.
>>>>>
>>>>> P.S.: Using version 0.2.0 (2013-11-16) on Linux Mint 32 bit system.
>>>>>
>>>>
>>>
>

Reply via email to