Merge pull request #367 from cypheon/bugfix/ttc-bigint-unmarshalling

Fix unmarshalling of Integer values in TTC (Fixes: #345)
This commit is contained in:
Edwin Brady 2020-05-19 19:38:15 +01:00 committed by GitHub
commit c0b7c6a9d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -383,17 +383,16 @@ count : List.Elem x xs -> Int
count Here = 0
count (There p) = 1 + count p
toLimbs : Integer -> List Int
toLimbs : Integer -> List Bits8
toLimbs x
= if x == 0
then []
else if x == -1 then [-1]
else fromInteger (prim__andBigInt x 0xffffffff) ::
toLimbs (prim__ashrBigInt x 32)
else fromInteger (prim__andBigInt x 0xff) ::
toLimbs (prim__ashrBigInt x 8)
fromLimbs : List Int -> Integer
fromLimbs : List Bits8 -> Integer
fromLimbs [] = 0
fromLimbs (x :: xs) = cast x + prim__shlBigInt (fromLimbs xs) 32
fromLimbs (x :: xs) = prim__zextB8_BigInt x + prim__shlBigInt (fromLimbs xs) 8
export
TTC Integer where

View File

@ -1,4 +1,4 @@
[3518437212327232157160858338944, 1537557061787000452679295093927559, 3518437212327232157160858338070, 8051343735302590748651849744, 379]
[3518437212345678901234567890560, 1537557061795061679839506167983751, 3518437212345678901234567889686, 8051343735344802977653473432, 339]
[8650625671965379659, 5435549321212129090, 8650625671965378905, 365458446121836181, 357]
1/1: Building Numbers (Numbers.idr)
Main> Main> Bye for now!