VM: Refactor float_bits.hpp to Factor style
parent
95d34e8ee7
commit
83b69d45f8
|
|
@ -1,45 +1,40 @@
|
||||||
namespace factor
|
namespace factor {
|
||||||
{
|
|
||||||
|
|
||||||
/* Some functions for converting floating point numbers to binary
|
/* Some functions for converting floating point numbers to binary
|
||||||
representations and vice versa */
|
representations and vice versa */
|
||||||
|
|
||||||
union double_bits_pun {
|
union double_bits_pun {
|
||||||
double x;
|
double x;
|
||||||
u64 y;
|
u64 y;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline static u64 double_bits(double x)
|
inline static u64 double_bits(double x) {
|
||||||
{
|
double_bits_pun b;
|
||||||
double_bits_pun b;
|
b.x = x;
|
||||||
b.x = x;
|
return b.y;
|
||||||
return b.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static double bits_double(u64 y)
|
inline static double bits_double(u64 y) {
|
||||||
{
|
double_bits_pun b;
|
||||||
double_bits_pun b;
|
b.y = y;
|
||||||
b.y = y;
|
return b.x;
|
||||||
return b.x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
union float_bits_pun {
|
union float_bits_pun {
|
||||||
float x;
|
float x;
|
||||||
u32 y;
|
u32 y;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline static u32 float_bits(float x)
|
inline static u32 float_bits(float x) {
|
||||||
{
|
float_bits_pun b;
|
||||||
float_bits_pun b;
|
b.x = x;
|
||||||
b.x = x;
|
return b.y;
|
||||||
return b.y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static float bits_float(u32 y)
|
inline static float bits_float(u32 y) {
|
||||||
{
|
float_bits_pun b;
|
||||||
float_bits_pun b;
|
b.y = y;
|
||||||
b.y = y;
|
return b.x;
|
||||||
return b.x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue