mirror of https://github.com/rm-dr/daisy
Fixed quantity printing
parent
bb200548f1
commit
cb227d9539
|
@ -4,4 +4,4 @@ pub mod quantity;
|
|||
pub use crate::quantity::quantity::Quantity;
|
||||
|
||||
const FLOAT_PRECISION: u32 = 2048;
|
||||
const PRINT_LEN: usize = 4; // How many significant digits we will show in output
|
||||
const PRINT_LEN: usize = 5; // How many significant digits we will show in output
|
|
@ -48,15 +48,16 @@ impl ToString for Quantity{
|
|||
exp_u = exp.try_into().unwrap()
|
||||
}
|
||||
|
||||
if exp_u >= 4 {
|
||||
if exp_u >= PRINT_LEN {
|
||||
// Exponential notation
|
||||
let pre = &string[0..1];
|
||||
let post = &string[1..];
|
||||
|
||||
format!(
|
||||
"{pre}{}{post}e{}{exp}",
|
||||
"{pre}{}{post}e{}",
|
||||
if post.len() != 0 {"."} else {""},
|
||||
if exp > 0 {"+"} else {""},
|
||||
//if exp > 0 {"+"} else {""},
|
||||
exp - 1
|
||||
)
|
||||
} else {
|
||||
if exp <= 0 { // Decimal, needs `0.` and leading zeros
|
||||
|
|
Loading…
Reference in New Issue