Is there an easy and fast way to get the position of the decimal point?
golddranks opened this issue · 1 comments
golddranks commented
Is there an easy and fast way to get the position of the decimal point, or possibly set the output precision in digits? I'd like to limit the number of output digits after the decimal point, and if information about the position of the decimal point would be available directly from the algorithm, it would be waste of cycles to scan it from the output buffer.
dtolnay commented
If you are concerned about cycles I would recommend building your own formatter around d2d which is the base2-to-base10 conversion in Ryū. It converts for example 1.0e-10f64 into mantissa=1u64 exponent=-10i32. Check out the two existing formatters, the default Ryū one here and the one we call pretty here.