ohler55/oj — pull request #202 by toofishes (2014-10-30 16:40:25+00:00)
Title: Fix float padding issues on certain decimal values

We were seeing things like this:
Oj.dump(-95.640172) => "-95.64017200000001"
Oj.dump(73.4) => "73.40000000000001"
Oj.dump(0.7032) => "0.7031999999999999"

This is obviously not right and not ideal. The precision specifier in
the sprintf() call in the dump routine was changed from 15 to 16 in
commit a7a4d73991fc, but not much verification to correctness was given
there. In any case, as the test cases clearly show, we are not "doing
the right thing".

This small change fixes the newly provided test cases, and breaks no
existing ones.

Finally, clean up some of the special float casing of '0.0' and use
strcpy("0.0") similar to what we do in the other branches.

---
If this change from 15 to 16 was made for a reason, I failed to see it, given the lack of test cases showing benefit, and nothing failed when we went back to the old value. This addresses issue #193, and the example case from there has been included as a test case.