-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestsgood first issueIndicates a good issue for first-time contributors to JuliaIndicates a good issue for first-time contributors to Juliahelp wantedIndicates that a maintainer wants help on an issue or pull requestIndicates that a maintainer wants help on an issue or pull requestmathsMathematical functionsMathematical functions
Description
Get the high bits of the product of two overflowing integers. Like this, but more efficient for 128-bit integers:
function mul_hi(x::T, y::T) where T <: Base.BitInteger
xy = widemul(x, y)
(xy >> 8sizeof(T)) % T
endmul_lo is just *.
mul_hi for BigInt could return 0, false, or error.
We could define mul_hi_lo instead to support non-overflowing integer types like SaferIntegers.
From discourse
NHDaly, adienes and chengchingwen
Metadata
Metadata
Assignees
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestsgood first issueIndicates a good issue for first-time contributors to JuliaIndicates a good issue for first-time contributors to Juliahelp wantedIndicates that a maintainer wants help on an issue or pull requestIndicates that a maintainer wants help on an issue or pull requestmathsMathematical functionsMathematical functions