knowing the correct `k` beforehand. We will call the mode of operation requiring `n` as to the *exact* mode, and one requiring `limit` as to the *fixed* mode. The exact mode is a subset of the fixed mode: the sufficiently large last-digit limitation will eventually fill the supplied buffer and let the algorithm to return. # Implementation overview It is easy to get the floating point printing correct but slow (Russ Cox has [demonstrated](https://research.swtch.com/ftoa) how it's easy), or incorrect but fast (naïve division and modulo). But it is surprisingly hard to print floating point numbers correctly *and* efficiently. There are two classes of algorithms widely known to be correct. - The "Dragon" family of algorithm is first described by Guy L. Steele Jr. and Jon L. White. They rely on the fixed-size big integer for their correctness. A slight improvement was found later, which is posthumously described by Robert G. Burger and R. Kent Dybvig. David Gay's `dtoa.c` routine is a popular implementation of this strategy. - The "Grisu" family of algorithm is first described by Florian Loitsch. They use very cheap integer-only procedure to determine the close-to-correct representation which is at least guaranteed to be shortest. The variant, Grisu3, actively detects if the resulting representation is incorrect. We implement both algorithms with necessary tweaks to suit our requirements. In particular, published literatures are short of the actual implementation difficulties like how to avoid arithmetic overflows. Each implementation, available in `strategy::dragon` and `strategy::grisu` respectively, extensively describes all necessary justifications and many proofs for them. (It is still difficult to follow though. You have been warned.) Both implementations expose two public functions: - `format_shortest(decoded, buf)`, which always needs at least `MAX_SIG_DIGITS` digits of buffer. Implements the shortest mode. - `format_exact(decoded, buf, limit)`, which accepts as small as one digit of buffer. Implements exact and fixed modes. They try to fill the `u8` buffer with digits and returns the number of digits written and the exponent `k`. They are total for all finite `f32` and `f64` inputs (Grisu internally falls back to Dragon if necessary). The rendered digits are formatted into the actual string form with four functions: - `to_shortest_str` prints the shortest representation, which can be padded by zeroes to make *at least* given number of fractional digits. - `to_shortest_exp_str` prints the shortest representation, which can be padded by zeroes when its exponent is in the specified ranges, or can be printed in the exponential form such as `1.23e45`. - `to_exact_exp_str` prints the exact representation with given number of digits in the exponential form. - `to_exact_fixed_str` prints the fixed representation with *exactly* given number of fractional digits. They all return a slice of preallocated `Part` array, which corresponds to the individual part of strings: a fixed string, a part of rendered digits, a number of zeroes or a small (`u16`) number. The caller is expected to provide a large enough buffer and `Part` array, and to assemble the final string from resulting `Part`s itself. All algorithms and formatting functions are accompanied by extensive tests in `coretests::num::flt2dec` module. It also shows how to use individual functions.