aboutsummaryrefslogtreecommitdiff
path: root/src/pack2b.h
blob: b63807ad94df918a28206b057d03e57ce72df3d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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