diff options
Diffstat (limited to 'util.rkt')
-rw-r--r-- | util.rkt | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -20,6 +20,7 @@ (provide integer->bytes integer->bytes/size bytes->integer + bytes->integer/le pad-bytes Justification Endianness @@ -58,6 +59,13 @@ (bitwise-ior (arithmetic-shift n 8) byte))) +(define: (bytes->integer/le [b : Bytes]) : Exact-Nonnegative-Integer + (for/fold: ([n : Exact-Nonnegative-Integer 0]) + ([byte : Byte (in-bytes b)] + [i : Integer (in-naturals)]) + (bitwise-ior (arithmetic-shift byte (* i 8)) + n))) + (define: (pad-bytes [b : Bytes] [s : Exact-Nonnegative-Integer] [fill : Byte] |