2 Numeric Packings
(require (planet murphy/packed-io/number)) |
This module provides packings of data represented as numeric values
of a fixed size.
2.1 Endianness Controls
(packing-big-endian?) → any/c |
(packing-big-endian? v) → void? |
v : any/c |
Parameter that determines whether data is stored in big-endian
format during packing or unpacking.
Defaults to the system’s native endianness (system-big-endian?).
(big-endian/p packing) → packing? |
packing : packing? |
Produces a wrapped version of packing that sets
(packing-big-endian? #t) while packing or unpacking.
(little-endian/p packing) → packing? |
packing : packing? |
Produces a wrapped version of packing that sets
(packing-big-endian? #f) while packing or unpacking.
(native-endian/p packing) → packing? |
packing : packing? |
Produces a wrapped version of packing that sets
(packing-big-endian? (system-big-endian?)) while packing or
unpacking.
2.2 Integers
(integer/p size signed?) → packing? |
size : (or/c 1 2 4 8) |
signed? : any/c |
Produces a packing for integral numbers into size
bytes. signed? determines whether the packed values are
signed or unsigned.
Standard integer packings with 8, 16, 32 and 64 bits representation
size. The packings whose names start with u are unsigned,
the others are signed.
Aliases for the standard integer packings with friendly names:
byte is 8 bits, short is 16 bits, int is
32 bits and long is 64 bits.
2.3 Reals
(real/p size) → packing? |
size : (or/c 4 8) |
Produces a packing for IEEE floating point numbers into
size bytes.
Standard floating point packings: float/p has 32 bits,
double/p has 64 bits representation size.
2.4 Derived Types
(character/p size) → packing? |
size : (or/c 1 2 4 8) |
Produces a packing of characters as size bytes long
unsigned integers.
Standard character packings: char/p has 8 bits,
wchar/p has 16 bits representation size.
Single byte packing of boolean values. #f is represented by
0, any other value maps to 1 while packing and any
other packed number maps to #t when unpacking.