feat: cap significant_digits to 10 in pretty_eval
This commit is contained in:
parent
c249d7cb41
commit
46c697234c
1 changed files with 3 additions and 1 deletions
|
|
@ -2,6 +2,8 @@ use rug::Float;
|
|||
|
||||
use crate::nodes::{self, Error};
|
||||
|
||||
pub const MAX_DIGITS: usize = 10;
|
||||
|
||||
pub fn pretty_eval(mut input: String) -> Result<String, Error> {
|
||||
// no need to remove the characters here,
|
||||
// as we ignore the them in all other logic already
|
||||
|
|
@ -17,7 +19,7 @@ pub fn pretty_eval(mut input: String) -> Result<String, Error> {
|
|||
.is_some();
|
||||
|
||||
let result = nodes::eval(&input)?;
|
||||
let significant_digits = get_significant_digits(&result);
|
||||
let significant_digits = get_significant_digits(&result).min(MAX_DIGITS);
|
||||
|
||||
Ok(format!(
|
||||
"{}{}{result:.significant_digits$}{}",
|
||||
|
|
|
|||
Loading…
Reference in a new issue