summaryrefslogtreecommitdiff
path: root/math.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-03 18:48:26 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-03 18:48:52 -0500
commit5a207b62cebb4673eb3422001e8d9435fca9f545 (patch)
tree802a86a4ea6ea05f036e293a3c2eba607457f644 /math.c
parentb72ce9a3fdfe956f566c8bdde1fceebe7601c59f (diff)
line numbering!
Diffstat (limited to 'math.c')
-rw-r--r--math.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/math.c b/math.c
index c177eef..1443267 100644
--- a/math.c
+++ b/math.c
@@ -70,6 +70,14 @@ static inline u32 clamp_u32(u32 x, u32 a, u32 b) {
return x;
}
+static inline u8 ndigits_u64(u64 x) {
+ u8 ndigits = 1;
+ while (x > 9) {
+ x /= 10;
+ ++ndigits;
+ }
+ return ndigits;
+}
// remap x from the interval [from_a, from_b] to the interval [to_a, to_b], NOT clamping if x is outside the "from" interval.
static inline float remapf(float x, float from_a, float from_b, float to_a, float to_b) {