diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-03 18:48:26 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-02-03 18:48:52 -0500 |
commit | 5a207b62cebb4673eb3422001e8d9435fca9f545 (patch) | |
tree | 802a86a4ea6ea05f036e293a3c2eba607457f644 /math.c | |
parent | b72ce9a3fdfe956f566c8bdde1fceebe7601c59f (diff) |
line numbering!
Diffstat (limited to 'math.c')
-rw-r--r-- | math.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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) { |