diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2021-05-26 09:59:32 -0400 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2021-05-26 09:59:32 -0400 |
commit | 1a9ba7bb0aeb27a7d0bca43190edd054e517f27b (patch) | |
tree | a925bd32e0745ddf3ecef23d1ef3e710f3250273 | |
parent | 5c965f5357c09a9eaaad029441401498e0877966 (diff) |
Revert typedefs in math_util
-rw-r--r-- | include/math_util.h | 23 | ||||
-rw-r--r-- | src/math_util.c | 18 |
2 files changed, 18 insertions, 23 deletions
diff --git a/include/math_util.h b/include/math_util.h index 29fa8f59d..1f8edc5d9 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -3,24 +3,19 @@ // 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 Q_8_8_mul(fx16 x, fx16 y); -fxn16 Q_N_S_mul(u8 s, fxn16 x, fxn16 y); -fx32 Q_24_8_mul(fx32 x, fx32 y); +s16 Q_8_8_mul(s16 x, s16 y); +s16 Q_N_S_mul(u8 s, s16 x, s16 y); +s32 Q_24_8_mul(s32 x, s32 y); // x / y -fx16 Q_8_8_div(fx16 x, fx16 y); -fxn16 Q_N_S_div(u8 s, fxn16 x, fxn16 y); -fx32 Q_24_8_div(fx32 x, fx32 y); +s16 Q_8_8_div(s16 x, s16 y); +s16 Q_N_S_div(u8 s, s16 x, s16 y); +s32 Q_24_8_div(s32 x, s32 y); // 1.0 / y -fx16 Q_8_8_inv(fx16 y); -fxn16 Q_N_S_inv(u8 s, fxn16 y); -fx32 Q_24_8_inv(fx32 y); +s16 Q_8_8_inv(s16 y); +s16 Q_N_S_inv(u8 s, s16 y); +s32 Q_24_8_inv(s32 y); #endif //GUARD_MATH_UTIL_H diff --git a/src/math_util.c b/src/math_util.c index eff2fd7c0..767e4d93d 100644 --- a/src/math_util.c +++ b/src/math_util.c @@ -1,7 +1,7 @@ #include "global.h" #include "math_util.h" -fx16 Q_8_8_mul(fx16 x, fx16 y) +s16 Q_8_8_mul(s16 x, s16 y) { s32 result; @@ -11,7 +11,7 @@ fx16 Q_8_8_mul(fx16 x, fx16 y) return result; } -fxn16 Q_N_S_mul(u8 s, fxn16 x, fxn16 y) +s16 Q_N_S_mul(u8 s, s16 x, s16 y) { s32 result; @@ -21,7 +21,7 @@ fxn16 Q_N_S_mul(u8 s, fxn16 x, fxn16 y) return result; } -fx32 Q_24_8_mul(fx32 x, fx32 y) +s32 Q_24_8_mul(s32 x, s32 y) { s64 result; @@ -31,7 +31,7 @@ fx32 Q_24_8_mul(fx32 x, fx32 y) return result; } -fx16 Q_8_8_div(fx16 x, fx16 y) +s16 Q_8_8_div(s16 x, s16 y) { if (y == 0) { @@ -40,7 +40,7 @@ fx16 Q_8_8_div(fx16 x, fx16 y) return (x << 8) / y; } -fxn16 Q_N_S_div(u8 s, fxn16 x, fxn16 y) +s16 Q_N_S_div(u8 s, s16 x, s16 y) { if (y == 0) { @@ -49,7 +49,7 @@ fxn16 Q_N_S_div(u8 s, fxn16 x, fxn16 y) return (x << s) / y; } -fx32 Q_24_8_div(fx32 x, fx32 y) +s32 Q_24_8_div(s32 x, s32 y) { s64 _x; @@ -62,7 +62,7 @@ fx32 Q_24_8_div(fx32 x, fx32 y) return _x / y; } -fx16 Q_8_8_inv(fx16 y) +s16 Q_8_8_inv(s16 y) { s32 x; @@ -70,7 +70,7 @@ fx16 Q_8_8_inv(fx16 y) return x / y; } -fxn16 Q_N_S_inv(u8 s, fxn16 y) +s16 Q_N_S_inv(u8 s, s16 y) { s32 x; @@ -78,7 +78,7 @@ fxn16 Q_N_S_inv(u8 s, fxn16 y) return x / y; } -fx32 Q_24_8_inv(fx32 y) +s32 Q_24_8_inv(s32 y) { s64 x; |