I will be writing dtoa, the original version includes rounding or truncation, or both ?
I will be writing dtoa, the original version includes rounding or truncation, or both ?
dtoa() is not a standard function, and it is usually described as "Double to ASCII".
Look at one implementation of the function which should answer your question, and show how one implementation has been written. There may be others on Github and other sites. Google for more results.
Printf only rounds, printf("|%.f| |%.1f| |%.2f| |%.5f| |%.12f", 0.000099, 0.000099, 0.000099, 0.000099, 0.000099);
output: |0| |0.0| |0.00| |0.00010| |0.000099000000
This is what I meant by truncation, "-12.520008900" is truncated to "-12.52", because of 3 consecutive '0'.
rstanley recommendation remains true: "Look at one implementtion of the function which should answer your question..."
The whole thing is cluttered and cryptic, the only one who will understand that is the author.
I just want to know if there is truncation.Code://dtoa.c word0(rvp) = ((b->x[1] & ~0x800000) >> 16) | ((e + 129 + 55) << 7) | (b->x[1] << 16);
Adding truncation and rounding is possible, but is there a need for truncation ?