@@ 187,7 187,11 @@
(define (deserialize-bignum _tag data)
(unless (bytes? data)
(error "Bignum payload must be bytes"))
- (integer-bytes->integer data #f #t))
+ (for/fold ([acc 0])
+ ([(chunk idx) (in-indexed data)])
+ (define shift (* 8 (- (sub1 (bytes-length data))
+ idx)))
+ (bitwise-ior acc (arithmetic-shift chunk shift))))
(define (deserialize-bigneg tag data)
(- -1 (deserialize-bignum tag data)))
@@ 256,9 260,9 @@
(check-eqv? (try "1a000f4240") 1000000)
(check-eqv? (try "1b000000e8d4a51000") 1000000000000)
(check-eqv? (try "1bffffffffffffffff") 18446744073709551615)
- ;TODO bignums (check-eqv? (try "c249010000000000000000") 18446744073709551616)
+ (check-eqv? (try "c249010000000000000000") 18446744073709551616)
(check-eqv? (try "3bffffffffffffffff") -18446744073709551616)
- ;TODO bignums (check-eqv? (try "c349010000000000000000") -18446744073709551617)
+ (check-eqv? (try "c349010000000000000000") -18446744073709551617)
(check-eqv? (try "20") -1)
(check-eqv? (try "29") -10)
(check-eqv? (try "3863") -100)