diff options
author | Erik Schnetter <schnetter@gmail.com> | 2012-12-01 16:08:57 -0500 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2012-12-01 16:08:57 -0500 |
commit | 471686ed980d1068aa5e5c8fb8289f8f81d33d39 (patch) | |
tree | c02940e1ca726573a20d117ca008fa50ea8c8039 /floatprops.h | |
parent | af41d3bc35d082cb4d8e793071a801b589978ce8 (diff) | |
download | vecmathlib-471686ed980d1068aa5e5c8fb8289f8f81d33d39.zip vecmathlib-471686ed980d1068aa5e5c8fb8289f8f81d33d39.tar.gz |
Implement sin, make optimised builds work
Diffstat (limited to 'floatprops.h')
-rw-r--r-- | floatprops.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/floatprops.h b/floatprops.h index 7048112..9058c23 100644 --- a/floatprops.h +++ b/floatprops.h @@ -61,8 +61,18 @@ namespace vecmathlib { "error in masks"); // Re-interpret bit patterns - static inline real_t as_float(int_t x) { return *(real_t*)&x; } - static inline int_t as_int(real_t x) { return *(int_t*)&x; } + static inline real_t as_float(int_t x) + { + // return *(real_t*)&x; + union { int_t i; real_t r; } ir; + return ir.i=x, ir.r; + } + static inline int_t as_int(real_t x) + { + // return *(int_t*)&x; + union { real_t r; int_t i; } ri; + return ri.r=x, ri.i; + } // Convert values static inline real_t convert_float(int_t x) { return real_t(x); } @@ -114,8 +124,18 @@ namespace vecmathlib { "error in masks"); // Re-interpret bit patterns - static inline real_t as_float(int_t x) { return *(real_t*)&x; } - static inline int_t as_int(real_t x) { return *(int_t*)&x; } + static inline real_t as_float(int_t x) + { + // return *(real_t*)&x; + union { int_t i; real_t r; } ir; + return ir.i=x, ir.r; + } + static inline int_t as_int(real_t x) + { + // return *(int_t*)&x; + union { real_t r; int_t i; } ri; + return ri.r=x, ri.i; + } // Convert values static inline real_t convert_float(int_t x) { return real_t(x); } |