Skip to content

Commit

Permalink
more 128-bit integer workarounds for shifts on 32-bit systems [#3596]
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Jul 1, 2013
1 parent de6cacd commit 1f582d1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions base/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,13 @@ mod(x::Int64, y::Int64) = box(Int64,smod_int(unbox(Int64,x),unbox(Int64,y)))
<<(x::Int16, y::Int32) = box(Int16,shl_int(unbox(Int16,x),unbox(Int32,y)))
<<(x::Int32, y::Int32) = box(Int32,shl_int(unbox(Int32,x),unbox(Int32,y)))
<<(x::Int64, y::Int32) = box(Int64,shl_int(unbox(Int64,x),unbox(Int32,y)))
if Int === Int64
<<(x::Int128, y::Int32) = box(Int128,shl_int(unbox(Int128,x),unbox(Int32,y)))
else
<<(x::Int128, y::Int32) = y==0 ? x : box(Int128,shl_int(unbox(Int128,x),unbox(Int32,y)))
end

<<(x::Uint8, y::Int32) = box(Uint8,shl_int(unbox(Uint8,x),unbox(Int32,y)))
<<(x::Uint16, y::Int32) = box(Uint16,shl_int(unbox(Uint16,x),unbox(Int32,y)))
<<(x::Uint32, y::Int32) = box(Uint32,shl_int(unbox(Int32,x),unbox(Uint32,y)))
<<(x::Uint64, y::Int32) = box(Uint64,shl_int(unbox(Uint64,x),unbox(Int32,y)))
if Int === Int64
<<(x::Uint128, y::Int32) = box(Uint128,shl_int(unbox(Uint128,x),unbox(Int32,y)))
else
<<(x::Uint128, y::Int32) = y==0 ? x : box(Uint128,shl_int(unbox(Uint128,x),unbox(Int32,y)))
end

>>(x::Int8, y::Int32) = box(Int8,ashr_int(unbox(Int8,x),unbox(Int32,y)))
>>(x::Int16, y::Int32) = box(Int16,ashr_int(unbox(Int16,x),unbox(Int32,y)))
Expand Down Expand Up @@ -554,6 +546,13 @@ if WORD_SIZE==32
rem(x::Uint128, y::Uint128) = uint128(rem(BigInt(x),BigInt(y)))

mod(x::Int128, y::Int128) = int128(mod(BigInt(x),BigInt(y)))

<< (x::Int128, y::Int32) = y == 0 ? x : box(Int128,shl_int(unbox(Int128,x),unbox(Int32,y)))
<< (x::Uint128, y::Int32) = y == 0 ? x : box(Uint128,shl_int(unbox(Uint128,x),unbox(Int32,y)))
>> (x::Int128, y::Int32) = y == 0 ? x : box(Int128,ashr_int(unbox(Int128,x),unbox(Int32,y)))
>> (x::Uint128, y::Int32) = y == 0 ? x : box(Uint128,lshr_int(unbox(Uint128,x),unbox(Int32,y)))
>>>(x::Int128, y::Int32) = y == 0 ? x : box(Int128,lshr_int(unbox(Int128,x),unbox(Int32,y)))
>>>(x::Uint128, y::Int32) = y == 0 ? x : box(Uint128,lshr_int(unbox(Uint128,x),unbox(Int32,y)))
else
widemul(u::Int64, v::Int64) = int128(u)*int128(v)
widemul(u::Uint64, v::Uint64) = uint128(u)*uint128(v)
Expand Down

0 comments on commit 1f582d1

Please sign in to comment.