(precision: usize, magnitude: f64, case: Case, alternate_form: bool)
| 55 | } |
| 56 | |
| 57 | pub fn format_fixed(precision: usize, magnitude: f64, case: Case, alternate_form: bool) -> String { |
| 58 | match magnitude { |
| 59 | magnitude if magnitude.is_finite() => { |
| 60 | let point = decimal_point_or_empty(precision, alternate_form); |
| 61 | let precision = core::cmp::min(precision, u16::MAX as usize); |
| 62 | format!("{magnitude:.precision$}{point}") |
| 63 | } |
| 64 | magnitude if magnitude.is_nan() => format_nan(case), |
| 65 | magnitude if magnitude.is_infinite() => format_inf(case), |
| 66 | _ => "".to_string(), |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | // Formats floats into Python style exponent notation, by first formatting in Rust style |
| 71 | // exponent notation (`1.0000e0`), then convert to Python style (`1.0000e+00`). |
no test coverage detected