From dac4c1baab68e81dd3194f10be011574f4cb8492 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 1 Dec 2024 16:26:33 -0500 Subject: fix some bad num/str conversion bugs --- main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index f5c93a7..d30b815 100644 --- a/main.cpp +++ b/main.cpp @@ -22,16 +22,19 @@ #include #include -constinit static sforth::forth<1024> forth {sforth::initialize<&forth>()}; +constinit static sforth::forth<2048> forth {sforth::initialize<&forth>()}; constinit static sforth::native_word<".", [](auto) { char buf[32] = {}; auto ptr = buf + sizeof(buf); auto v = forth.pop(); + bool neg = v < 0; + if (neg) v = -v; *--ptr = '\0'; do { *--ptr = "0123456789abcdefghijklmnopqrstuvwxyz"[v % forth.base]; } while (v /= forth.base); + if (neg) *--ptr = '-'; std::cout << ptr << ' '; }> dot; constinit static sforth::native_word<"emit", [](auto) { -- cgit v1.2.3