Yeah, this is an issue and there's no good solution. Returning an Int64 would imply that the abs function either always promotes to Int64 – which sucks and forces you into 64-bit computations on 32-bit platforms, where they tend to be very slow – or that abs is not type stable, which sucks even more. And what do you do on 64-bit platforms? Have abs return an Int128? That's just crazy. It might be reasonable to have abs return a same-sized unsigned integer, but then you get switched into unsigned arithmetic territory, which may be annoying.
On Wed, Feb 12, 2014 at 10:56 AM, <[email protected]> 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. >
