Open jealouscloud opened 6 years ago
I'm writing an application that needs binary equality with json doubles saved from the browser.
This library ports the double/string conversion from https://github.com/google/double-conversion with a few missing spots. I plan to investigate.
Using the test string: "4521.400000000001", should be rounded to 4521.4000000000005 which is what double-conversion returns, and therefore the v8 javascript engine.
"4521.400000000001"
4521.4000000000005
running StringToDoubleConverter.ToDouble returns 4521.4000000000015, which is inconsistent with the ported algorithm. I think this is because https://github.com/neuecc/Utf8Json/blob/master/src/Utf8Json/Internal/DoubleConversion/StringToDouble.cs#L471 around here, part of the algorithm port was cut short in favor of using .net double.Parse, which does not return consistent-with-google numbers.
4521.4000000000015
The ideal solution is to implement the missing parts from double-conversion.
Yes, implementing the correct fallback seems to have fixed the issue for stringtodouble. Once i do the same for doubletostring I'll make a PR
I'm writing an application that needs binary equality with json doubles saved from the browser.
This library ports the double/string conversion from https://github.com/google/double-conversion with a few missing spots. I plan to investigate.
Using the test string:
"4521.400000000001"
, should be rounded to4521.4000000000005
which is what double-conversion returns, and therefore the v8 javascript engine.running StringToDoubleConverter.ToDouble returns
4521.4000000000015
, which is inconsistent with the ported algorithm. I think this is because https://github.com/neuecc/Utf8Json/blob/master/src/Utf8Json/Internal/DoubleConversion/StringToDouble.cs#L471 around here, part of the algorithm port was cut short in favor of using .net double.Parse, which does not return consistent-with-google numbers.The ideal solution is to implement the missing parts from double-conversion.