Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-08-21 10:42:40 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-08-21 10:42:40 +0300
commit7e3781179e3eb37fdd1e8a65fcdfed898b8cf460 (patch)
tree3e19015b19d1e8904d231b77840f7a47ffc56df5 /source/blender/blenlib/intern/math_bits_inline.c
parentc727fc59abe2b7e525bdc6594bbd7ec3285936e0 (diff)
Math Lib: Add float/int conversion functions
Diffstat (limited to 'source/blender/blenlib/intern/math_bits_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_bits_inline.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_bits_inline.c b/source/blender/blenlib/intern/math_bits_inline.c
index 11ee6e7fa5b..82d7e2114c2 100644
--- a/source/blender/blenlib/intern/math_bits_inline.c
+++ b/source/blender/blenlib/intern/math_bits_inline.c
@@ -56,4 +56,37 @@ MINLINE int count_bits_i(unsigned int i)
}
#endif
+MINLINE int float_as_int(float f)
+{
+ union { int i; float f; } u;
+ u.f = f;
+ return u.i;
+}
+
+MINLINE unsigned int float_as_uint(float f)
+{
+ union { unsigned int i; float f; } u;
+ u.f = f;
+ return u.i;
+}
+
+MINLINE float int_as_float(int i)
+{
+ union { int i; float f; } u;
+ u.i = i;
+ return u.f;
+}
+
+MINLINE float uint_as_float(unsigned int i)
+{
+ union { unsigned int i; float f; } u;
+ u.i = i;
+ return u.f;
+}
+
+MINLINE float xor_fl(float x, int y)
+{
+ return int_as_float(float_as_int(x) ^ y);
+}
+
#endif /* __MATH_BITS_INLINE_C__ */