# Scientific Notation Decimal Places

Why give 2 decimal places when asking for .1e?

Current behaviour:

``````    assert_eq!("1.0e3", format!("{:.1e}", 1001));
assert_eq!("1.0e3", format!("{:.1e}", 1000));
assert_eq!("1.00e3", format!("{:.1e}", 999));
``````

Expected behaviour:

``````    assert_eq!("1.0e3", format!("{:.1e}", 999));
``````
2 Likes

Looks like a bug to me.

Kinda-sorta-understandable, but still a bug.

Worth opening an issue, I think.

1 Like

Going by the documentation of this feature

## Precision

For non-numeric types, this can be considered a āmaximum widthā. If the resulting string is longer than this width, then it is truncated down to this many characters and that truncated value is emitted with proper `fill`, `alignment` and `width` if those parameters are set.

For integral types, this is ignored.

For floating-point types, this indicates how many digits after the decimal point should be printed.

Edit: On a quick search, I couldnāt fined any relevant existing issues myself yet.

4 Likes

will do, thanks very much for checking

IMO, ideally, a test like this should pass:

``````let [mut s1, mut s2]: [String; 2] = Default::default();

for x in -2000_i64..=2000 {
let xf = x as f64;

macro_rules! test {
(\$fmt:literal, \$assert_fmt:literal) => {
s1.clear();
s2.clear();
write!(&mut s1, \$fmt, x).unwrap();
write!(&mut s2, \$fmt, xf).unwrap();
assert_eq!(
&s1,
&s2,
"exponential formatting of integers vs. integral floats\nformat!(\"{}\", {})",
format_args!(\$assert_fmt),
x
);
};
}

test!("{:e}", "{{:e}}");
test!("{:E}", "{{:E}}");

for n in 0..5 {
test!("{:.n\$e}", "{{:.{n}e}}");
test!("{:.n\$E}", "{{:.{n}E}}");
}
}
``````

Right now, there are a lot of differences:

``````format!("{:.0e}",  -999) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -998) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -997) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -996) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -995) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -994) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -993) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -992) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -991) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -990) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -989) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -988) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -987) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -986) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -985) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -984) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -983) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -982) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -981) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -980) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -979) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -978) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -977) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -976) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -975) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -974) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -973) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -972) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -971) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -970) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -969) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -968) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -967) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -966) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -965) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -964) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -963) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -962) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -961) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -960) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -959) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -958) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -957) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -956) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -955) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -954) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -953) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -952) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -951) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -950) --> i64: "-1.0e3"  f64: "-1e3"
format!("{:.0e}",  -850) --> i64: "-9e2"    f64: "-8e2"
format!("{:.0e}",  -650) --> i64: "-7e2"    f64: "-6e2"
format!("{:.0e}",  -450) --> i64: "-5e2"    f64: "-4e2"
format!("{:.0e}",  -250) --> i64: "-3e2"    f64: "-2e2"
format!("{:.0e}",   -99) --> i64: "-1.0e2"  f64: "-1e2"
format!("{:.0e}",   -98) --> i64: "-1.0e2"  f64: "-1e2"
format!("{:.0e}",   -97) --> i64: "-1.0e2"  f64: "-1e2"
format!("{:.0e}",   -96) --> i64: "-1.0e2"  f64: "-1e2"
format!("{:.0e}",   -95) --> i64: "-1.0e2"  f64: "-1e2"
format!("{:.0e}",   -85) --> i64: "-9e1"    f64: "-8e1"
format!("{:.0e}",   -65) --> i64: "-7e1"    f64: "-6e1"
format!("{:.0e}",   -45) --> i64: "-5e1"    f64: "-4e1"
format!("{:.0e}",   -25) --> i64: "-3e1"    f64: "-2e1"
format!("{:.0e}",    25) --> i64: "3e1"     f64: "2e1"
format!("{:.0e}",    45) --> i64: "5e1"     f64: "4e1"
format!("{:.0e}",    65) --> i64: "7e1"     f64: "6e1"
format!("{:.0e}",    85) --> i64: "9e1"     f64: "8e1"
format!("{:.0e}",    95) --> i64: "1.0e2"   f64: "1e2"
format!("{:.0e}",    96) --> i64: "1.0e2"   f64: "1e2"
format!("{:.0e}",    97) --> i64: "1.0e2"   f64: "1e2"
format!("{:.0e}",    98) --> i64: "1.0e2"   f64: "1e2"
format!("{:.0e}",    99) --> i64: "1.0e2"   f64: "1e2"
format!("{:.0e}",   250) --> i64: "3e2"     f64: "2e2"
format!("{:.0e}",   450) --> i64: "5e2"     f64: "4e2"
format!("{:.0e}",   650) --> i64: "7e2"     f64: "6e2"
format!("{:.0e}",   850) --> i64: "9e2"     f64: "8e2"
format!("{:.0e}",   950) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   951) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   952) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   953) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   954) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   955) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   956) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   957) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   958) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   959) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   960) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   961) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   962) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   963) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   964) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   965) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   966) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   967) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   968) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   969) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   970) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   971) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   972) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   973) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   974) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   975) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   976) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   977) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   978) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   979) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   980) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   981) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   982) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   983) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   984) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   985) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   986) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   987) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   988) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   989) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   990) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   991) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   992) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   993) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   994) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   995) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   996) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   997) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   998) --> i64: "1.0e3"   f64: "1e3"
format!("{:.0e}",   999) --> i64: "1.0e3"   f64: "1e3"
format!("{:.1e}", -1850) --> i64: "-1.9e3"  f64: "-1.8e3"
format!("{:.1e}", -1650) --> i64: "-1.7e3"  f64: "-1.6e3"
format!("{:.1e}", -1450) --> i64: "-1.5e3"  f64: "-1.4e3"
format!("{:.1e}", -1250) --> i64: "-1.3e3"  f64: "-1.2e3"
format!("{:.1e}", -1050) --> i64: "-1.1e3"  f64: "-1.0e3"
format!("{:.1e}",  -999) --> i64: "-1.00e3" f64: "-1.0e3"
format!("{:.1e}",  -998) --> i64: "-1.00e3" f64: "-1.0e3"
format!("{:.1e}",  -997) --> i64: "-1.00e3" f64: "-1.0e3"
format!("{:.1e}",  -996) --> i64: "-1.00e3" f64: "-1.0e3"
format!("{:.1e}",  -995) --> i64: "-1.00e3" f64: "-1.0e3"
format!("{:.1e}",  -985) --> i64: "-9.9e2"  f64: "-9.8e2"
format!("{:.1e}",  -965) --> i64: "-9.7e2"  f64: "-9.6e2"
format!("{:.1e}",  -945) --> i64: "-9.5e2"  f64: "-9.4e2"
format!("{:.1e}",  -925) --> i64: "-9.3e2"  f64: "-9.2e2"
format!("{:.1e}",  -905) --> i64: "-9.1e2"  f64: "-9.0e2"
format!("{:.1e}",  -885) --> i64: "-8.9e2"  f64: "-8.8e2"
format!("{:.1e}",  -865) --> i64: "-8.7e2"  f64: "-8.6e2"
format!("{:.1e}",  -845) --> i64: "-8.5e2"  f64: "-8.4e2"
format!("{:.1e}",  -825) --> i64: "-8.3e2"  f64: "-8.2e2"
format!("{:.1e}",  -805) --> i64: "-8.1e2"  f64: "-8.0e2"
format!("{:.1e}",  -785) --> i64: "-7.9e2"  f64: "-7.8e2"
format!("{:.1e}",  -765) --> i64: "-7.7e2"  f64: "-7.6e2"
format!("{:.1e}",  -745) --> i64: "-7.5e2"  f64: "-7.4e2"
format!("{:.1e}",  -725) --> i64: "-7.3e2"  f64: "-7.2e2"
format!("{:.1e}",  -705) --> i64: "-7.1e2"  f64: "-7.0e2"
format!("{:.1e}",  -685) --> i64: "-6.9e2"  f64: "-6.8e2"
format!("{:.1e}",  -665) --> i64: "-6.7e2"  f64: "-6.6e2"
format!("{:.1e}",  -645) --> i64: "-6.5e2"  f64: "-6.4e2"
format!("{:.1e}",  -625) --> i64: "-6.3e2"  f64: "-6.2e2"
format!("{:.1e}",  -605) --> i64: "-6.1e2"  f64: "-6.0e2"
format!("{:.1e}",  -585) --> i64: "-5.9e2"  f64: "-5.8e2"
format!("{:.1e}",  -565) --> i64: "-5.7e2"  f64: "-5.6e2"
format!("{:.1e}",  -545) --> i64: "-5.5e2"  f64: "-5.4e2"
format!("{:.1e}",  -525) --> i64: "-5.3e2"  f64: "-5.2e2"
format!("{:.1e}",  -505) --> i64: "-5.1e2"  f64: "-5.0e2"
format!("{:.1e}",  -485) --> i64: "-4.9e2"  f64: "-4.8e2"
format!("{:.1e}",  -465) --> i64: "-4.7e2"  f64: "-4.6e2"
format!("{:.1e}",  -445) --> i64: "-4.5e2"  f64: "-4.4e2"
format!("{:.1e}",  -425) --> i64: "-4.3e2"  f64: "-4.2e2"
format!("{:.1e}",  -405) --> i64: "-4.1e2"  f64: "-4.0e2"
format!("{:.1e}",  -385) --> i64: "-3.9e2"  f64: "-3.8e2"
format!("{:.1e}",  -365) --> i64: "-3.7e2"  f64: "-3.6e2"
format!("{:.1e}",  -345) --> i64: "-3.5e2"  f64: "-3.4e2"
format!("{:.1e}",  -325) --> i64: "-3.3e2"  f64: "-3.2e2"
format!("{:.1e}",  -305) --> i64: "-3.1e2"  f64: "-3.0e2"
format!("{:.1e}",  -285) --> i64: "-2.9e2"  f64: "-2.8e2"
format!("{:.1e}",  -265) --> i64: "-2.7e2"  f64: "-2.6e2"
format!("{:.1e}",  -245) --> i64: "-2.5e2"  f64: "-2.4e2"
format!("{:.1e}",  -225) --> i64: "-2.3e2"  f64: "-2.2e2"
format!("{:.1e}",  -205) --> i64: "-2.1e2"  f64: "-2.0e2"
format!("{:.1e}",  -185) --> i64: "-1.9e2"  f64: "-1.8e2"
format!("{:.1e}",  -165) --> i64: "-1.7e2"  f64: "-1.6e2"
format!("{:.1e}",  -145) --> i64: "-1.5e2"  f64: "-1.4e2"
format!("{:.1e}",  -125) --> i64: "-1.3e2"  f64: "-1.2e2"
format!("{:.1e}",  -105) --> i64: "-1.1e2"  f64: "-1.0e2"
format!("{:.1e}",   105) --> i64: "1.1e2"   f64: "1.0e2"
format!("{:.1e}",   125) --> i64: "1.3e2"   f64: "1.2e2"
format!("{:.1e}",   145) --> i64: "1.5e2"   f64: "1.4e2"
format!("{:.1e}",   165) --> i64: "1.7e2"   f64: "1.6e2"
format!("{:.1e}",   185) --> i64: "1.9e2"   f64: "1.8e2"
format!("{:.1e}",   205) --> i64: "2.1e2"   f64: "2.0e2"
format!("{:.1e}",   225) --> i64: "2.3e2"   f64: "2.2e2"
format!("{:.1e}",   245) --> i64: "2.5e2"   f64: "2.4e2"
format!("{:.1e}",   265) --> i64: "2.7e2"   f64: "2.6e2"
format!("{:.1e}",   285) --> i64: "2.9e2"   f64: "2.8e2"
format!("{:.1e}",   305) --> i64: "3.1e2"   f64: "3.0e2"
format!("{:.1e}",   325) --> i64: "3.3e2"   f64: "3.2e2"
format!("{:.1e}",   345) --> i64: "3.5e2"   f64: "3.4e2"
format!("{:.1e}",   365) --> i64: "3.7e2"   f64: "3.6e2"
format!("{:.1e}",   385) --> i64: "3.9e2"   f64: "3.8e2"
format!("{:.1e}",   405) --> i64: "4.1e2"   f64: "4.0e2"
format!("{:.1e}",   425) --> i64: "4.3e2"   f64: "4.2e2"
format!("{:.1e}",   445) --> i64: "4.5e2"   f64: "4.4e2"
format!("{:.1e}",   465) --> i64: "4.7e2"   f64: "4.6e2"
format!("{:.1e}",   485) --> i64: "4.9e2"   f64: "4.8e2"
format!("{:.1e}",   505) --> i64: "5.1e2"   f64: "5.0e2"
format!("{:.1e}",   525) --> i64: "5.3e2"   f64: "5.2e2"
format!("{:.1e}",   545) --> i64: "5.5e2"   f64: "5.4e2"
format!("{:.1e}",   565) --> i64: "5.7e2"   f64: "5.6e2"
format!("{:.1e}",   585) --> i64: "5.9e2"   f64: "5.8e2"
format!("{:.1e}",   605) --> i64: "6.1e2"   f64: "6.0e2"
format!("{:.1e}",   625) --> i64: "6.3e2"   f64: "6.2e2"
format!("{:.1e}",   645) --> i64: "6.5e2"   f64: "6.4e2"
format!("{:.1e}",   665) --> i64: "6.7e2"   f64: "6.6e2"
format!("{:.1e}",   685) --> i64: "6.9e2"   f64: "6.8e2"
format!("{:.1e}",   705) --> i64: "7.1e2"   f64: "7.0e2"
format!("{:.1e}",   725) --> i64: "7.3e2"   f64: "7.2e2"
format!("{:.1e}",   745) --> i64: "7.5e2"   f64: "7.4e2"
format!("{:.1e}",   765) --> i64: "7.7e2"   f64: "7.6e2"
format!("{:.1e}",   785) --> i64: "7.9e2"   f64: "7.8e2"
format!("{:.1e}",   805) --> i64: "8.1e2"   f64: "8.0e2"
format!("{:.1e}",   825) --> i64: "8.3e2"   f64: "8.2e2"
format!("{:.1e}",   845) --> i64: "8.5e2"   f64: "8.4e2"
format!("{:.1e}",   865) --> i64: "8.7e2"   f64: "8.6e2"
format!("{:.1e}",   885) --> i64: "8.9e2"   f64: "8.8e2"
format!("{:.1e}",   905) --> i64: "9.1e2"   f64: "9.0e2"
format!("{:.1e}",   925) --> i64: "9.3e2"   f64: "9.2e2"
format!("{:.1e}",   945) --> i64: "9.5e2"   f64: "9.4e2"
format!("{:.1e}",   965) --> i64: "9.7e2"   f64: "9.6e2"
format!("{:.1e}",   985) --> i64: "9.9e2"   f64: "9.8e2"
format!("{:.1e}",   995) --> i64: "1.00e3"  f64: "1.0e3"
format!("{:.1e}",   996) --> i64: "1.00e3"  f64: "1.0e3"
format!("{:.1e}",   997) --> i64: "1.00e3"  f64: "1.0e3"
format!("{:.1e}",   998) --> i64: "1.00e3"  f64: "1.0e3"
format!("{:.1e}",   999) --> i64: "1.00e3"  f64: "1.0e3"
format!("{:.1e}",  1050) --> i64: "1.1e3"   f64: "1.0e3"
format!("{:.1e}",  1250) --> i64: "1.3e3"   f64: "1.2e3"
format!("{:.1e}",  1450) --> i64: "1.5e3"   f64: "1.4e3"
format!("{:.1e}",  1650) --> i64: "1.7e3"   f64: "1.6e3"
format!("{:.1e}",  1850) --> i64: "1.9e3"   f64: "1.8e3"
format!("{:.2e}", -1985) --> i64: "-1.99e3" f64: "-1.98e3"
format!("{:.2e}", -1965) --> i64: "-1.97e3" f64: "-1.96e3"
format!("{:.2e}", -1945) --> i64: "-1.95e3" f64: "-1.94e3"
format!("{:.2e}", -1925) --> i64: "-1.93e3" f64: "-1.92e3"
format!("{:.2e}", -1905) --> i64: "-1.91e3" f64: "-1.90e3"
format!("{:.2e}", -1885) --> i64: "-1.89e3" f64: "-1.88e3"
format!("{:.2e}", -1865) --> i64: "-1.87e3" f64: "-1.86e3"
format!("{:.2e}", -1845) --> i64: "-1.85e3" f64: "-1.84e3"
format!("{:.2e}", -1825) --> i64: "-1.83e3" f64: "-1.82e3"
format!("{:.2e}", -1805) --> i64: "-1.81e3" f64: "-1.80e3"
format!("{:.2e}", -1785) --> i64: "-1.79e3" f64: "-1.78e3"
format!("{:.2e}", -1765) --> i64: "-1.77e3" f64: "-1.76e3"
format!("{:.2e}", -1745) --> i64: "-1.75e3" f64: "-1.74e3"
format!("{:.2e}", -1725) --> i64: "-1.73e3" f64: "-1.72e3"
format!("{:.2e}", -1705) --> i64: "-1.71e3" f64: "-1.70e3"
format!("{:.2e}", -1685) --> i64: "-1.69e3" f64: "-1.68e3"
format!("{:.2e}", -1665) --> i64: "-1.67e3" f64: "-1.66e3"
format!("{:.2e}", -1645) --> i64: "-1.65e3" f64: "-1.64e3"
format!("{:.2e}", -1625) --> i64: "-1.63e3" f64: "-1.62e3"
format!("{:.2e}", -1605) --> i64: "-1.61e3" f64: "-1.60e3"
format!("{:.2e}", -1585) --> i64: "-1.59e3" f64: "-1.58e3"
format!("{:.2e}", -1565) --> i64: "-1.57e3" f64: "-1.56e3"
format!("{:.2e}", -1545) --> i64: "-1.55e3" f64: "-1.54e3"
format!("{:.2e}", -1525) --> i64: "-1.53e3" f64: "-1.52e3"
format!("{:.2e}", -1505) --> i64: "-1.51e3" f64: "-1.50e3"
format!("{:.2e}", -1485) --> i64: "-1.49e3" f64: "-1.48e3"
format!("{:.2e}", -1465) --> i64: "-1.47e3" f64: "-1.46e3"
format!("{:.2e}", -1445) --> i64: "-1.45e3" f64: "-1.44e3"
format!("{:.2e}", -1425) --> i64: "-1.43e3" f64: "-1.42e3"
format!("{:.2e}", -1405) --> i64: "-1.41e3" f64: "-1.40e3"
format!("{:.2e}", -1385) --> i64: "-1.39e3" f64: "-1.38e3"
format!("{:.2e}", -1365) --> i64: "-1.37e3" f64: "-1.36e3"
format!("{:.2e}", -1345) --> i64: "-1.35e3" f64: "-1.34e3"
format!("{:.2e}", -1325) --> i64: "-1.33e3" f64: "-1.32e3"
format!("{:.2e}", -1305) --> i64: "-1.31e3" f64: "-1.30e3"
format!("{:.2e}", -1285) --> i64: "-1.29e3" f64: "-1.28e3"
format!("{:.2e}", -1265) --> i64: "-1.27e3" f64: "-1.26e3"
format!("{:.2e}", -1245) --> i64: "-1.25e3" f64: "-1.24e3"
format!("{:.2e}", -1225) --> i64: "-1.23e3" f64: "-1.22e3"
format!("{:.2e}", -1205) --> i64: "-1.21e3" f64: "-1.20e3"
format!("{:.2e}", -1185) --> i64: "-1.19e3" f64: "-1.18e3"
format!("{:.2e}", -1165) --> i64: "-1.17e3" f64: "-1.16e3"
format!("{:.2e}", -1145) --> i64: "-1.15e3" f64: "-1.14e3"
format!("{:.2e}", -1125) --> i64: "-1.13e3" f64: "-1.12e3"
format!("{:.2e}", -1105) --> i64: "-1.11e3" f64: "-1.10e3"
format!("{:.2e}", -1085) --> i64: "-1.09e3" f64: "-1.08e3"
format!("{:.2e}", -1065) --> i64: "-1.07e3" f64: "-1.06e3"
format!("{:.2e}", -1045) --> i64: "-1.05e3" f64: "-1.04e3"
format!("{:.2e}", -1025) --> i64: "-1.03e3" f64: "-1.02e3"
format!("{:.2e}", -1005) --> i64: "-1.01e3" f64: "-1.00e3"
format!("{:.2e}",  1005) --> i64: "1.01e3"  f64: "1.00e3"
format!("{:.2e}",  1025) --> i64: "1.03e3"  f64: "1.02e3"
format!("{:.2e}",  1045) --> i64: "1.05e3"  f64: "1.04e3"
format!("{:.2e}",  1065) --> i64: "1.07e3"  f64: "1.06e3"
format!("{:.2e}",  1085) --> i64: "1.09e3"  f64: "1.08e3"
format!("{:.2e}",  1105) --> i64: "1.11e3"  f64: "1.10e3"
format!("{:.2e}",  1125) --> i64: "1.13e3"  f64: "1.12e3"
format!("{:.2e}",  1145) --> i64: "1.15e3"  f64: "1.14e3"
format!("{:.2e}",  1165) --> i64: "1.17e3"  f64: "1.16e3"
format!("{:.2e}",  1185) --> i64: "1.19e3"  f64: "1.18e3"
format!("{:.2e}",  1205) --> i64: "1.21e3"  f64: "1.20e3"
format!("{:.2e}",  1225) --> i64: "1.23e3"  f64: "1.22e3"
format!("{:.2e}",  1245) --> i64: "1.25e3"  f64: "1.24e3"
format!("{:.2e}",  1265) --> i64: "1.27e3"  f64: "1.26e3"
format!("{:.2e}",  1285) --> i64: "1.29e3"  f64: "1.28e3"
format!("{:.2e}",  1305) --> i64: "1.31e3"  f64: "1.30e3"
format!("{:.2e}",  1325) --> i64: "1.33e3"  f64: "1.32e3"
format!("{:.2e}",  1345) --> i64: "1.35e3"  f64: "1.34e3"
format!("{:.2e}",  1365) --> i64: "1.37e3"  f64: "1.36e3"
format!("{:.2e}",  1385) --> i64: "1.39e3"  f64: "1.38e3"
format!("{:.2e}",  1405) --> i64: "1.41e3"  f64: "1.40e3"
format!("{:.2e}",  1425) --> i64: "1.43e3"  f64: "1.42e3"
format!("{:.2e}",  1445) --> i64: "1.45e3"  f64: "1.44e3"
format!("{:.2e}",  1465) --> i64: "1.47e3"  f64: "1.46e3"
format!("{:.2e}",  1485) --> i64: "1.49e3"  f64: "1.48e3"
format!("{:.2e}",  1505) --> i64: "1.51e3"  f64: "1.50e3"
format!("{:.2e}",  1525) --> i64: "1.53e3"  f64: "1.52e3"
format!("{:.2e}",  1545) --> i64: "1.55e3"  f64: "1.54e3"
format!("{:.2e}",  1565) --> i64: "1.57e3"  f64: "1.56e3"
format!("{:.2e}",  1585) --> i64: "1.59e3"  f64: "1.58e3"
format!("{:.2e}",  1605) --> i64: "1.61e3"  f64: "1.60e3"
format!("{:.2e}",  1625) --> i64: "1.63e3"  f64: "1.62e3"
format!("{:.2e}",  1645) --> i64: "1.65e3"  f64: "1.64e3"
format!("{:.2e}",  1665) --> i64: "1.67e3"  f64: "1.66e3"
format!("{:.2e}",  1685) --> i64: "1.69e3"  f64: "1.68e3"
format!("{:.2e}",  1705) --> i64: "1.71e3"  f64: "1.70e3"
format!("{:.2e}",  1725) --> i64: "1.73e3"  f64: "1.72e3"
format!("{:.2e}",  1745) --> i64: "1.75e3"  f64: "1.74e3"
format!("{:.2e}",  1765) --> i64: "1.77e3"  f64: "1.76e3"
format!("{:.2e}",  1785) --> i64: "1.79e3"  f64: "1.78e3"
format!("{:.2e}",  1805) --> i64: "1.81e3"  f64: "1.80e3"
format!("{:.2e}",  1825) --> i64: "1.83e3"  f64: "1.82e3"
format!("{:.2e}",  1845) --> i64: "1.85e3"  f64: "1.84e3"
format!("{:.2e}",  1865) --> i64: "1.87e3"  f64: "1.86e3"
format!("{:.2e}",  1885) --> i64: "1.89e3"  f64: "1.88e3"
format!("{:.2e}",  1905) --> i64: "1.91e3"  f64: "1.90e3"
format!("{:.2e}",  1925) --> i64: "1.93e3"  f64: "1.92e3"
format!("{:.2e}",  1945) --> i64: "1.95e3"  f64: "1.94e3"
format!("{:.2e}",  1965) --> i64: "1.97e3"  f64: "1.96e3"
format!("{:.2e}",  1985) --> i64: "1.99e3"  f64: "1.98e3"
``````

Besides the behavior you described, resulting in the wrong number of digits, thereās also the rounding behavior that is different between displaying floats and ints here. Iām not sure whether or not this difference is wanted. If it is wanted, it should be properly documented (on that note, I couldnāt easily find any documentation on the rounding used for floats, either), if it isnāt, it would be yet another issue or bug.

3 Likes

Looks like we have an issue now ^^

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.