akubera / bigdecimal-rs

Arbitrary precision decimal crate for Rust
Other
275 stars 71 forks source link

Print bigdecimal without trailing zeros #85

Closed incker closed 1 year ago

incker commented 2 years ago

Code:

let num1 = BigDecimal::from_str("1.000").unwrap();
let num2 = BigDecimal::try_from(1.0f64).unwrap();

println!("{}", num1.to_string());
println!("{}", num2.to_string());

Output:

1.000
1.000000000000000

The question is how to make string from BigDecimal without trailing zeros Thank you

randomairborne commented 1 year ago

Yeah, you can call normalized()