Created
November 11, 2016 14:22
-
-
Save sjrd/bef82371f48f829ff39e2c3bd28820a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inline | |
def *(b: RuntimeLong): RuntimeLong = { | |
val alo = a.lo | |
val blo = b.lo | |
val a0 = alo & 0xffff | |
val a1 = alo >>> 16 | |
val b0 = blo & 0xffff | |
val b1 = blo >>> 16 | |
val a0b0 = a0 * b0 | |
val a1b0 = a1 * b0 | |
val a0b1 = a0 * b1 | |
val lo = a0b0 + ((a1b0 + a0b1) << 16) | |
val c1part = (a0b0 >>> 16) + a0b1 | |
val hi = { | |
alo*b.hi + a.hi*blo + a1 * b1 + | |
(c1part >>> 16) + (((c1part & 0xffff) + a1b0) >>> 16) | |
} | |
new RuntimeLong(lo, hi) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment