From fbf131b5c043b27e0b1543374bb144e3e426f723 Mon Sep 17 00:00:00 2001 From: Tyler Murphy <=> Date: Sun, 16 Jul 2023 02:54:32 -0400 Subject: initial --- libk/src/math/frexp.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 libk/src/math/frexp.c (limited to 'libk/src/math/frexp.c') diff --git a/libk/src/math/frexp.c b/libk/src/math/frexp.c new file mode 100644 index 0000000..16b8dd3 --- /dev/null +++ b/libk/src/math/frexp.c @@ -0,0 +1,19 @@ +#include + +double frexp(double arg, int* exp) { + *exp = 0; + while (arg > 1) { + arg /= 2;; + (*exp)++; + } + return arg; +} + +float frexpf(float arg, int* exp) { + *exp = 0; + while (arg > 1) { + arg /= 2; + (*exp)++; + } + return arg; +} -- cgit v1.2.3-freya