diff options
Diffstat (limited to 'src/pack2b.h')
-rw-r--r-- | src/pack2b.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pack2b.h b/src/pack2b.h new file mode 100644 index 0000000..b63807a --- /dev/null +++ b/src/pack2b.h @@ -0,0 +1,27 @@ +#ifndef PACK2B_H +#define PACK2B_H + +#include <stdint.h> + +// various bits for floating point types--varies for different architectures +typedef float float32_t; +typedef double float64_t; + +// macros for packing floats and doubles: +#define pack754_32(f) (pack754((f), 32, 8)) +#define pack754_64(f) (pack754((f), 64, 11)) +#define unpack754_32(i) (unpack754((i), 32, 8)) +#define unpack754_64(i) (unpack754((i), 64, 11)) + +uint64_t pack754(long double f, unsigned bits, unsigned expbits); +long double unpack754(uint64_t i, unsigned bits, unsigned expbits); +void packi16(uint8_t *buf, int16_t i); +void packi32(uint8_t *buf, int32_t i); +void packi64(uint8_t *buf, int64_t i); +int16_t unpacki16(uint8_t *buf); +int32_t unpacki32(uint8_t *buf); +int64_t unpacki64(uint8_t *buf); +int32_t pack(uint8_t *buf, char *format, ...); +void unpack(uint8_t *buf, char *format, ...); + +#endif |