Jens Axboe | 90f326d | 2011-10-05 08:43:47 +0200 | [diff] [blame] | 1 | #ifndef FIO_IEEE754_H |
| 2 | #define FIO_IEEE754_H |
| 3 | |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 4 | #include <inttypes.h> |
| 5 | |
Jens Axboe | 90f326d | 2011-10-05 08:43:47 +0200 | [diff] [blame] | 6 | extern uint64_t pack754(long double f, unsigned bits, unsigned expbits); |
| 7 | extern long double unpack754(uint64_t i, unsigned bits, unsigned expbits); |
| 8 | |
| 9 | #define fio_double_to_uint64(val) pack754((val), 64, 11) |
| 10 | #define fio_uint64_to_double(val) unpack754((val), 64, 11) |
| 11 | |
Jens Axboe | 802ad4a | 2011-10-05 09:51:58 +0200 | [diff] [blame] | 12 | typedef struct fio_fp64 { |
| 13 | union { |
| 14 | uint64_t i; |
| 15 | double f; |
| 16 | uint8_t filler[16]; |
| 17 | } u; |
| 18 | } fio_fp64_t; |
| 19 | |
Jens Axboe | 90f326d | 2011-10-05 08:43:47 +0200 | [diff] [blame] | 20 | #endif |