]> gitweb.factorcode.org Git - factor.git/blob - vm/float_bits.hpp
Put brackets around ipv6 addresses in `inet6 present`
[factor.git] / vm / float_bits.hpp
1 namespace factor {
2
3 // Some functions for converting floating point numbers to binary
4 // representations and vice versa
5
6 union double_bits_pun {
7   double x;
8   uint64_t y;
9 };
10
11 inline static uint64_t double_bits(double x) {
12   double_bits_pun b;
13   b.x = x;
14   return b.y;
15 }
16
17 inline static double bits_double(uint64_t y) {
18   double_bits_pun b;
19   b.y = y;
20   return b.x;
21 }
22
23 union float_bits_pun {
24   float x;
25   uint32_t y;
26 };
27
28 inline static uint32_t float_bits(float x) {
29   float_bits_pun b;
30   b.x = x;
31   return b.y;
32 }
33
34 inline static float bits_float(uint32_t y) {
35   float_bits_pun b;
36   b.y = y;
37   return b.x;
38 }
39
40 }