Skip to content

Commit

Permalink
[api] Small fixes.
Browse files Browse the repository at this point in the history
- UI now shows floats with 3 trailing digits by default.
- FmtReal produce better results.
  • Loading branch information
travisdoor committed Dec 1, 2024
1 parent 88acd27 commit a4cf551
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/bl/api/extra/ui/ui.bl
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/bl/api/std/print/print.bl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit a4cf551

Please sign in to comment.