summaryrefslogtreecommitdiff
path: root/stage3/font.c
diff options
context:
space:
mode:
authorLizzy Fleckenstein <lizzy@vlhl.dev>2023-12-21 06:40:40 +0100
committerLizzy Fleckenstein <lizzy@vlhl.dev>2023-12-21 06:40:40 +0100
commit1ad6bbe4b3baee113bf6f37e0d02030910543fbd (patch)
tree52c419e11d50d1940911dba73b8c39eb8617724f /stage3/font.c
parent5885cb0a19b06388222f2945d78963377e584ecc (diff)
downloadcuddles-1ad6bbe4b3baee113bf6f37e0d02030910543fbd.tar.xz
add maths library and print_dbl
Diffstat (limited to 'stage3/font.c')
-rw-r--r--stage3/font.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/stage3/font.c b/stage3/font.c
index f47c9c9..3bbba86 100644
--- a/stage3/font.c
+++ b/stage3/font.c
@@ -3,6 +3,8 @@
#include "gfx.h"
#include "heap.h"
#include "memory.h"
+#include "math.h"
+
#include "font_builtin.c"
// important: must be a multiple of 2, else code won't work
@@ -197,3 +199,15 @@ void print_hex(u64 x)
print_num(x, 16);
}
+void print_dbl(double d, u8 points)
+{
+ if (d < 0) {
+ print_char('-');
+ d = -d;
+ }
+
+ long i = d;
+ print_dec(i);
+ print_char('.');
+ print_num_pad((d - (double) i) * (double) ipow(10, points), 10, points, '0');
+}