Closed GoogleCodeExporter closed 9 years ago
Hi thanks for the comment.
It's really a documentation bug. The code works fine, unless you are saying
otherwise.
the pow10 array is for floating point precision. So a precision of 1 will using
pow10[1] in the array (i.e. 10).
The code works by doing something like this
Given 1234.1
remove print integer part. (1234)
then with the faction, multiple by pow10[precision]
so 0.1 * 10 = 1
print that.
if the precision is 0, then the factional part is not printed.
Looking at the code, it appears that pow10[0] could be 1 and it would work just
fine.
I'll fool around and see what is most clear. If anything I'll update the docs
int whole = (int) value;
double tmp = (value - whole) * pow10[prec];
uint32_t frac = (uint32_t)(tmp);
if (tmp - frac > 0.5) {
++frac;
}
thanks again!
--nickg
Original comment by nickgsup...@gmail.com
on 28 Sep 2007 at 12:20
I think this all cleared up now.
thanks,
closing
Original comment by nickgsup...@gmail.com
on 7 Jan 2008 at 1:21
Original issue reported on code.google.com by
superstr...@gmail.com
on 24 Sep 2007 at 4:30