docs(formatting): add note
This commit is contained in:
parent
f60c8749a0
commit
7a1049fda9
1 changed files with 7 additions and 0 deletions
|
|
@ -13,6 +13,13 @@ pub fn pretty_eval(input: &str, max_digits: usize) -> Result<String, Error> {
|
|||
let result = nodes::eval(&input)?;
|
||||
let display_digits = get_significant_digits(&result).clamp(1, max_digits);
|
||||
|
||||
// this helps improve the output formatting,
|
||||
// by not using scientific notation when it doesn't make sense.
|
||||
//
|
||||
// it does this by parsing the string, which is unfortunate.
|
||||
// ideally, this would be done by reimplementing the display code;
|
||||
// but neither I nor Edeth know how to do that yet.
|
||||
// (much like with `get_significant_digits`)
|
||||
let mut changing_string = format!("{result:.display_digits$}");
|
||||
if let Some(index) = changing_string.find('e')
|
||||
&& ((changing_string.chars().nth(index + 1).unwrap() == '-'
|
||||
|
|
|
|||
Loading…
Reference in a new issue