mirror of
https://github.com/status-im/nim-stew.git
synced 2025-01-23 10:29:44 +00:00
fix 32-bit
This commit is contained in:
parent
422b1540de
commit
e9b227758e
@ -109,7 +109,7 @@ func mulWiden*(x, y: uint): tuple[lo, hi: uint] =
|
|||||||
when sizeof(uint) == sizeof(uint64):
|
when sizeof(uint) == sizeof(uint64):
|
||||||
let (a, b) = mulWiden(uint64(x), uint64(y))
|
let (a, b) = mulWiden(uint64(x), uint64(y))
|
||||||
else:
|
else:
|
||||||
let (a, b) = mulWiden(uint32(x), uint64(y))
|
let (a, b) = mulWiden(uint32(x), uint32(y))
|
||||||
(uint(a), uint(b))
|
(uint(a), uint(b))
|
||||||
|
|
||||||
func mulWiden*(x, y, carry: SomeUnsignedInt): tuple[lo, hi: SomeUnsignedInt] =
|
func mulWiden*(x, y, carry: SomeUnsignedInt): tuple[lo, hi: SomeUnsignedInt] =
|
||||||
|
@ -42,8 +42,6 @@ template testMulWiden[T: SomeUnsignedInt]() =
|
|||||||
doAssert mulWiden(T(2), T(2)) == (T(4), T(0))
|
doAssert mulWiden(T(2), T(2)) == (T(4), T(0))
|
||||||
doAssert mulWiden(T.high, T(1)) == (T.high, T(0))
|
doAssert mulWiden(T.high, T(1)) == (T.high, T(0))
|
||||||
doAssert mulWiden(T(1), T.high) == (T.high, T(0))
|
doAssert mulWiden(T(1), T.high) == (T.high, T(0))
|
||||||
echo mulWiden(T.high, T.high)
|
|
||||||
echo T.high
|
|
||||||
doAssert mulWiden(T.high, T.high) == (T(1), T.high - 1)
|
doAssert mulWiden(T.high, T.high) == (T(1), T.high - 1)
|
||||||
|
|
||||||
doAssert mulWiden(T.high, T.high, T(0)) == (T(1), T.high - 1)
|
doAssert mulWiden(T.high, T.high, T(0)) == (T(1), T.high - 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user