MCPcopy
hub / github.com/Effect-TS/effect / mul64

Function mul64

packages/effect/src/Utils.ts:657–687  ·  view source on GitHub ↗
(
  out: Int32Array,
  aHi: number,
  aLo: number,
  bHi: number,
  bLo: number
)

Source from the content-addressed store, hash-verified

655}
656
657function mul64(
658 out: Int32Array,
659 aHi: number,
660 aLo: number,
661 bHi: number,
662 bLo: number
663): void {
664 let c1 = ((aLo >>> 16) * (bLo & 0xffff)) >>> 0
665 let c0 = ((aLo & 0xffff) * (bLo >>> 16)) >>> 0
666
667 let lo = ((aLo & 0xffff) * (bLo & 0xffff)) >>> 0
668 let hi = ((aLo >>> 16) * (bLo >>> 16) + ((c0 >>> 16) + (c1 >>> 16))) >>> 0
669
670 c0 = (c0 << 16) >>> 0
671 lo = (lo + c0) >>> 0
672 if ((lo >>> 0) < (c0 >>> 0)) {
673 hi = (hi + 1) >>> 0
674 }
675
676 c1 = (c1 << 16) >>> 0
677 lo = (lo + c1) >>> 0
678 if ((lo >>> 0) < (c1 >>> 0)) {
679 hi = (hi + 1) >>> 0
680 }
681
682 hi = (hi + Math.imul(aLo, bHi)) >>> 0
683 hi = (hi + Math.imul(aHi, bLo)) >>> 0
684
685 out[0] = hi
686 out[1] = lo
687}
688
689// add two 64 bit numbers (given in parts), and store the result in `out`.
690function add64(

Callers 1

_nextMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…