Function std::num::flt2dec::to_shortest_exp_str
[−]
[src]
pub fn to_shortest_exp_str<T, F>(format_shortest: F, v: T, sign: Sign, dec_bounds: (i16, i16), upper: bool, buf: &'a mut [u8], parts: &'a mut [Part<'a>]) -> Formatted<'a> where F: FnMut(&Decoded, &mut [u8]) -> (usize, i16), T: DecodableFloat
flt2dec
): internal routines only exposed for testing
Formats given floating point number into the decimal form or
the exponential form, depending on the resulting exponent. The result is
stored to the supplied parts array while utilizing given byte buffer
as a scratch. upper
is used to determine the case of non-finite values
(inf
and nan
) or the case of the exponent prefix (e
or E
).
The first part to be rendered is always a Part::Sign
(which can be
an empty string if no sign is rendered).
format_shortest
should be the underlying digit-generation function.
You probably would want strategy::grisu::format_shortest
for this.
The dec_bounds
is a tuple (lo, hi)
such that the number is formatted
as decimal only when 10^lo <= V < 10^hi
. Note that this is the apparent V
instead of the actual v
! Thus any printed exponent in the exponential form
cannot be in this range, avoiding any confusion.
The byte buffer should be at least MAX_SIG_DIGITS
bytes long.
There should be at least 7 parts available, due to the worst case like
[+][1][.][2345][e][-][67]
.