fix stuint constructor

This commit is contained in:
jangko 2023-06-13 08:13:39 +07:00
parent 0dc6afe9d4
commit e5c352fde2
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
1 changed files with 4 additions and 2 deletions

View File

@ -45,9 +45,11 @@ template static_check_size(T: typedesc[SomeInteger], bits: static[int]) =
func stuint*[T: SomeInteger](n: T, bits: static[int]): StUint[bits] {.inline.}=
## Converts an integer to an arbitrary precision integer.
result.limbs[0] = Word(n)
when sizeof(n) > sizeof(Word):
result.limbs[1] = Word(n) shr WordBitWidth
result.limbs[0] = Word(n and Word.high)
result.limbs[1] = Word(n shr WordBitWidth)
else:
result.limbs[0] = Word(n)
# func stint*[T: SomeInteger](n: T, bits: static[int]): StInt[bits] {.inline.}=
# ## Converts an integer to an arbitrary precision signed integer.