Closed GoogleCodeExporter closed 9 years ago
Oh course I remember! Hello!
Can you provide some sample values or a test case, so I can get this in faster?
I can't think of any reason why we would want to preserve the trailing zeros --
people can uses printf if they
want that level of control.
Original comment by nickgsup...@gmail.com
on 18 Mar 2010 at 1:59
The use case for this is that we need a faster replacement for sprintf(s,
"%.14g",
n). We are using Lua for scripting and this is exactly how it internally
converts
numbers to strings. In our testing we found that in some our applications we are
spending quite a lot of time in number to string conversions so we just wanted
to
optimize it by replacing sprintf with something faster. Not removing trailing
zeros
generally doesn't work well for Lua as it only has double as a native numeric
type.
So you have to store integers as doubles as well and if you don't strip trailing
zeros they look ugly when printing them say to log files.
As for a test case you can just compare the result with sprintf(s, "%.XXg", n)
output
where XX is precision.
Original comment by ilya.m...@gmail.com
on 18 Mar 2010 at 5:21
thanks for the background.
I'll take a look tonight.
Original comment by nickgsup...@gmail.com
on 18 Mar 2010 at 6:38
Interesting.
Instead of flags, I just made another function modp_dtoa2. Testing turned out
to be tricky since this format-
style does not exist within printf! However, it's in, with tests.
svn ci -m 'Issue 9: dtoa2, same as dtoa2 but with no trailing zeros after the
decimal point'
Sending src/modp_numtoa.c
Sending src/modp_numtoa.h
Sending test/modp_numtoa_test.c
Transmitting file data ...
Committed revision 222.
I also noticed that there are no tests for Inf/Nan. I'll make a new release
once those work correctly.
Original comment by nickgsup...@gmail.com
on 19 Mar 2010 at 2:05
Original issue reported on code.google.com by
ilya.m...@gmail.com
on 18 Mar 2010 at 9:42