From e5c352fde24b87d0214d8aa9df9470cbd416cceb Mon Sep 17 00:00:00 2001 From: jangko Date: Tue, 13 Jun 2023 08:13:39 +0700 Subject: [PATCH] fix stuint constructor --- stint/io.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stint/io.nim b/stint/io.nim index 6120ab4..bd311bb 100644 --- a/stint/io.nim +++ b/stint/io.nim @@ -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.