Is there there a way to format a Float with a particular precision? #3055
Unanswered
wezm
asked this question in
Questions & support
Replies: 1 comment
-
A function for this would be good! I seem to recall someone working on one but I can't see it now.
These are extremely complex features, especially from a typing point of view. I think it's probably better to have regular functions for this, but I'm open to any language design proposals for sure |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I haven't been able to find anything in the stdlib but wanted to double check: is there a built-in way to format a float with specified number of decimal places?
E.g.
format!("{:.1}", 99.123)
in Rust for 1 digit after the decimal place, producing 99.1. I can code something up for my particular case but something akin toformat!
/printf
might be useful generally.Beta Was this translation helpful? Give feedback.
All reactions