@@ -93,7 +93,7 @@ Both implementations expose two public functions:
93
93
94
94
They try to fill the `u8` buffer with digits and returns the number of digits
95
95
written and the exponent `k`. They are total for all finite `f32` and `f64`
96
- inputs (Grisu internally falls back to Dragon if possible ).
96
+ inputs (Grisu internally falls back to Dragon if necessary ).
97
97
98
98
The rendered digits are formatted into the actual string form with
99
99
four functions:
@@ -114,8 +114,8 @@ four functions:
114
114
They all return a slice of preallocated `Part` array, which corresponds to
115
115
the individual part of strings: a fixed string, a part of rendered digits,
116
116
a number of zeroes or a small (`u16`) number. The caller is expected to
117
- provide an enough buffer and `Part` array, and to assemble the final
118
- string from parts itself.
117
+ provide a large enough buffer and `Part` array, and to assemble the final
118
+ string from resulting `Part`s itself.
119
119
120
120
All algorithms and formatting functions are accompanied by extensive tests
121
121
in `coretest::num::flt2dec` module. It also shows how to use individual
@@ -274,7 +274,7 @@ fn digits_to_dec_str<'a>(buf: &'a [u8], exp: i16, frac_digits: usize,
274
274
275
275
// if there is the restriction on the last digit position, `buf` is assumed to be
276
276
// left-padded with the virtual zeroes. the number of virtual zeroes, `nzeroes`,
277
- // equals to `max(0, exp + frag_digits - buf.len())`, so that the position of
277
+ // equals to `max(0, exp + frac_digits - buf.len())`, so that the position of
278
278
// the last digit `exp - buf.len() - nzeroes` is no more than `-frac_digits`:
279
279
//
280
280
// |<-virtual->|
@@ -373,7 +373,7 @@ pub enum Sign {
373
373
/// Prints `-` only for the negative non-zero values.
374
374
Minus , // -inf -1 0 0 1 inf nan
375
375
/// Prints `-` only for any negative values (including the negative zero).
376
- MinusRaw , // -inf -1 0 0 1 inf nan
376
+ MinusRaw , // -inf -1 - 0 0 1 inf nan
377
377
/// Prints `-` for the negative non-zero values, or `+` otherwise.
378
378
MinusPlus , // -inf -1 +0 +0 +1 +inf nan
379
379
/// Prints `-` for any negative values (including the negative zero), or `+` otherwise.
@@ -639,9 +639,8 @@ pub fn to_exact_fixed_str<'a, T, F>(mut format_exact: F, v: T,
639
639
let limit = if frac_digits < 0x8000 { -( frac_digits as i16 ) } else { i16:: MIN } ;
640
640
let ( len, exp) = format_exact ( decoded, & mut buf[ ..maxlen] , limit) ;
641
641
if exp <= limit {
642
- // `format_exact` always returns at least one digit even though the restriction
643
- // hasn't been met, so we catch this condition and treats as like zeroes.
644
- // this does not include the case that the restriction has been met
642
+ // the restriction couldn't been met, so this should render like zero no matter
643
+ // `exp` was. this does not include the case that the restriction has been met
645
644
// only after the final rounding-up; it's a regular case with `exp = limit + 1`.
646
645
debug_assert_eq ! ( len, 0 ) ;
647
646
if frac_digits > 0 { // [0.][0000]
0 commit comments