summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2021-05-06 09:27:56 -0400
committerPikalaxALT <pikalaxalt@gmail.com>2021-05-06 09:27:56 -0400
commitf2847354f42e7bc62279a713f9331a900f9c7c75 (patch)
treee1b51cf04680dd062f960ba5e2f9062dfd33713c /include
parentda67ad94b6918e110aa737e0dd80ac2f76a40746 (diff)
Improve documentation of math_util
Diffstat (limited to 'include')
-rw-r--r--include/math_util.h27
1 files changed, 21 insertions, 6 deletions
diff --git a/include/math_util.h b/include/math_util.h
index 1ccde1ef5..b1243df56 100644
--- a/include/math_util.h
+++ b/include/math_util.h
@@ -1,11 +1,26 @@
#ifndef GUARD_MATH_UTIL_H
#define GUARD_MATH_UTIL_H
-s16 invfx16(s16 y);
-s16 mulfx16(s16 x, s16 y);
-s32 divfx32(s32 x, s32 y);
-s32 mulfx32(s32 x, s32 y);
-s16 divfxn16(u8 s, s16 x, s16 y);
-s16 mulfxn16(u8 s, s16 x, s16 y);
+// Fixed-point arithmetic library.
+
+// Proposed TODO: Move the macros here from global.h
+typedef s16 fx16; // Fixed-point Q8.8
+typedef s16 fxn16; // Fixed-point with arbitrary precision (QN.S)
+typedef s32 fx32; // Fixed-point Q24.8
+
+// x * y
+fx16 mulfx16(fx16 x, fx16 y);
+fxn16 mulfxn16(u8 s, fxn16 x, fxn16 y);
+fx32 mulfx32(fx32 x, fx32 y);
+
+// x / y
+fx16 divfx16(fx16 x, fx16 y);
+fxn16 divfxn16(u8 s, fxn16 x, fxn16 y);
+fx32 divfx32(fx32 x, fx32 y);
+
+// 1.0 / y
+fx16 invfx16(fx16 y);
+fxn16 invfxn16(u8 s, fxn16 y);
+fx32 invfx32(fx32 y);
#endif //GUARD_MATH_UTIL_H