Function core::num::flt2dec::to_exact_fixed_str
source · pub fn to_exact_fixed_str<'a, T, F>(
format_exact: F,
v: T,
sign: Sign,
frac_digits: usize,
buf: &'a mut [MaybeUninit<u8>],
parts: &'a mut [MaybeUninit<Part<'a>>]
) -> Formatted<'a>where
T: DecodableFloat,
F: FnMut(&Decoded, &'a mut [MaybeUninit<u8>], i16) -> (&'a [u8], i16),
flt2dec
)Expand description
Formats given floating point number into the decimal form with exactly
given number of fractional digits. The result is stored to the supplied parts
array while utilizing given byte buffer as a scratch. upper
is currently
unused but left for the future decision to change the case of non-finite values,
i.e., inf
and nan
. The first part to be rendered is always a Part::Sign
(which can be an empty string if no sign is rendered).
format_exact
should be the underlying digit-generation function.
It should return the part of the buffer that it initialized.
You probably would want strategy::grisu::format_exact
for this.
The byte buffer should be enough for the output unless frac_digits
is
so large that only the fixed number of digits will be ever written.
(The tipping point for f64
is about 800, and 1000 bytes should be enough.)
There should be at least 4 parts available, due to the worst case like
[+][0.][0000][2][0000]
with frac_digits = 10
.