aboutsummaryrefslogtreecommitdiff
path: root/formatting.h
diff options
context:
space:
mode:
authorJoel Kronqvist <joelkronqvist@proton.me>2024-04-07 10:53:40 +0300
committerJoel Kronqvist <joelkronqvist@proton.me>2024-04-07 10:53:40 +0300
commitf975594e55bdc05ee436bc7bdcd6e09aec5357b1 (patch)
treee1ddb07ab967bbe9eb6a14865e7413b9b2e1ea0c /formatting.h
parent1ef526c695df4b37aa184867fb5b62c93118aa02 (diff)
downloadstdu-f975594e55bdc05ee436bc7bdcd6e09aec5357b1.tar.gz
stdu-f975594e55bdc05ee436bc7bdcd6e09aec5357b1.zip
Finished implementation for formatting for human readability
Diffstat (limited to 'formatting.h')
-rw-r--r--formatting.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/formatting.h b/formatting.h
new file mode 100644
index 0000000..b9ef53b
--- /dev/null
+++ b/formatting.h
@@ -0,0 +1,30 @@
+
+#ifndef FORMATTING_IS_IMPORTED
+#define FORMATTING_IS_IMPORTED
+
+struct exp_val {
+ int mantissa;
+ int exponent;
+ int base;
+};
+typedef struct exp_val exp_notated;
+
+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);
+const char* prefix(exp_notated x);
+int int_floored_with_binary_prefix(char** res, size_t* res_bufsize, int x);
+int int_floored_with_prefix(char** res, size_t* res_bufsize, int x, unsigned int precision);
+
+#endif