From c2a60d9b4ff9f70505a6240e1e960e7c6230e4af Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 11 Dec 2025 17:32:26 -0500 Subject: Print reals --- src/stdlib/print.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/stdlib/print.c') diff --git a/src/stdlib/print.c b/src/stdlib/print.c index 7da1343f..5d90d6c3 100644 --- a/src/stdlib/print.c +++ b/src/stdlib/print.c @@ -7,13 +7,16 @@ #include "fpconv.h" #include "print.h" +#include "reals.h" #include "util.h" public int _print_int(FILE *f, int64_t n) { + if (n == 0) return fputc('0', f); char buf[21] = {[20] = 0}; // Big enough for INT64_MIN + '\0' char *p = &buf[19]; bool negative = n < 0; + if (negative) n = -n; do { *(p--) = '0' + (n % 10); @@ -92,6 +95,9 @@ int _print_double(FILE *f, double n) { return (int)fwrite(buf, sizeof(char), (size_t)len, f); } +public +int _print_real(FILE *f, Real_t n) { return Text$print(f, Real$value_as_text(n, 10)); } + public int _print_hex_double(FILE *f, hex_double_t hex) { if (hex.d != hex.d) return fputs("NAN", f); -- cgit v1.2.3