From e26279107edf7012e6b9cd558aaa09a8f0ca4764 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 23 Mar 2024 17:56:49 +0200 Subject: Initial commit --- intmath.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 intmath.h (limited to 'intmath.h') diff --git a/intmath.h b/intmath.h new file mode 100644 index 0000000..b71334c --- /dev/null +++ b/intmath.h @@ -0,0 +1,33 @@ + +#ifndef INTMATH_IS_IMPORTED +#define INTMATH_IS_IMPORTED + +struct exp_val { + int mantissa; + int exponent; + int base; +}; +typedef struct exp_val exp_notated; + +int int_pow10(unsigned int exp); +int int_floor(int x, int precision); +int int_ceil(int x, int precision); +int int_max(int a, int b); +int int_min(int a, int b); +exp_notated int_floored_exponent_notation_base( + int x, + unsigned int precision, + unsigned int base +); +exp_notated int_ceiled_exponent_notation_base( + int x, + unsigned int precision, + unsigned int base +); +exp_notated int_floored_exponent_notation(int x, unsigned int precision); +exp_notated int_ceiled_exponent_notation(int x, unsigned int precision); +int exp_notated_to_int(exp_notated x); +const char* binary_prefix(exp_notated x); +char* int_floored_with_binary_prefix(int x); + +#endif -- cgit v1.2.3