summaryrefslogtreecommitdiff
path: root/lib/ieee754.h
blob: 5af9518eee3c28b77dde967d4f120caa66cd2fe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#ifndef FIO_IEEE754_H
#define FIO_IEEE754_H

#include <inttypes.h>

extern uint64_t pack754(long double f, unsigned bits, unsigned expbits);
extern long double unpack754(uint64_t i, unsigned bits, unsigned expbits);

#define fio_double_to_uint64(val)	pack754((val), 64, 11)
#define fio_uint64_to_double(val)	unpack754((val), 64, 11)

typedef struct fio_fp64 {
	union {
		uint64_t i;
		double f;
		uint8_t filler[16];
	} u;
} fio_fp64_t;

#endif