]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/float_bits.hpp
io.streams.256color: faster by caching styles
[factor.git] / vm / float_bits.hpp
index a60d42f97c5da5954cdd3c90cef4fec0601fe755..3a2e1474c4db98ec22e922f6c8f6775129dd4422 100644 (file)
@@ -1,40 +1,40 @@
-/* Some functions for converting floating point numbers to binary
-representations and vice versa */
-
-typedef union {
-    double x;
-    u64 y;
-} F_DOUBLE_BITS;
-
-INLINE u64 double_bits(double x)
-{
-       F_DOUBLE_BITS b;
-       b.x = x;
-       return b.y;
+namespace factor {
+
+// Some functions for converting floating point numbers to binary
+// representations and vice versa
+
+union double_bits_pun {
+  double x;
+  uint64_t y;
+};
+
+inline static uint64_t double_bits(double x) {
+  double_bits_pun b;
+  b.x = x;
+  return b.y;
 }
 
-INLINE double bits_double(u64 y)
-{
-       F_DOUBLE_BITS b;
-       b.y = y;
-       return b.x;
+inline static double bits_double(uint64_t y) {
+  double_bits_pun b;
+  b.y = y;
+  return b.x;
 }
 
-typedef union {
-    float x;
-    u32 y;
-} F_FLOAT_BITS;
+union float_bits_pun {
+  float x;
+  uint32_t y;
+};
+
+inline static uint32_t float_bits(float x) {
+  float_bits_pun b;
+  b.x = x;
+  return b.y;
+}
 
-INLINE u32 float_bits(float x)
-{
-       F_FLOAT_BITS b;
-       b.x = x;
-       return b.y;
+inline static float bits_float(uint32_t y) {
+  float_bits_pun b;
+  b.y = y;
+  return b.x;
 }
 
-INLINE float bits_float(u32 y)
-{
-       F_FLOAT_BITS b;
-       b.y = y;
-       return b.x;
 }