From a4cf551bb1eeb4de99e60f14a0f2f3e7b814b04a Mon Sep 17 00:00:00 2001 From: Martin Dorazil Date: Sun, 1 Dec 2024 01:40:20 +0100 Subject: [PATCH] [api] Small fixes. - UI now shows floats with 3 trailing digits by default. - FmtReal produce better results. --- lib/bl/api/extra/ui/ui.bl | 2 +- lib/bl/api/std/print/print.bl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bl/api/extra/ui/ui.bl b/lib/bl/api/extra/ui/ui.bl index ba8a64c4..e70e6db0 100644 --- a/lib/bl/api/extra/ui/ui.bl +++ b/lib/bl/api/extra/ui/ui.bl @@ -1506,7 +1506,7 @@ floatbox_impl :: fn (rect: Rect, value: *f32, flags := TextboxFlags.DEFAULT, sty using std; str_clear(&num_conversion_tmp); - str_append(&num_conversion_tmp, fmt_real(@value, 2)); + str_append(&num_conversion_tmp, fmt_real(@value, 3)); if textbox_impl(rect, &num_conversion_tmp, flags | TextboxFlags.NUMBER_INPUT, style, null, index, loc) { n, err :: strtof64(&num_conversion_tmp); if !err { diff --git a/lib/bl/api/std/print/print.bl b/lib/bl/api/std/print/print.bl index eb9bddc2..b15da98e 100644 --- a/lib/bl/api/std/print/print.bl +++ b/lib/bl/api/std/print/print.bl @@ -633,7 +633,7 @@ print_f64 :: fn (buf: *?T, cur: *s32, v: f64, trailing: s32) { if adjusted_trailing != 0 { print_string(buf, cur, "."); fpart = fpart * std.pow(10., auto adjusted_trailing); - print_u64(buf, cur, cast(u64) std.ceil(fpart), FmtIntBase.DEC, adjusted_trailing); + print_u64(buf, cur, cast(u64) std.round(fpart), FmtIntBase.DEC, adjusted_trailing); } }