Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
rpc: Avoid unnecessary parsing roundtrip in number formatting, fix locale issue #6456
Three weakly related fixes to number handling after the
Make ValueFromAmount always return 8 decimals
This is the format that was always returned to JSON clients. The difference was not noticed before, because VREAL values are post-processed by univalue.
By implementing the functionality directly it breaks the dependency of rpcserver on utilmoneystr. FormatMoney is now only used for debugging purposes.
To test, port over the formatting tests from util_tests.cpp to rpc_tests.cpp.
univalue: Avoid unnecessary roundtrip through double for numbers
JSON makes no distinction between numbers and reals, and our code doesn't need to do so either.
This removes VREAL, as well as its specific post-processing in
util: use locale-independent parsing in ParseDouble
Use locale-indepent C++ based parsing instead of C's strtod, which checks for different input based on the user's locale.
referenced this pull request
Jul 18, 2015
changed the title from
rpc: Avoid unnecessary roundtrips in number parsing, fix locale issue
rpc: Avoid unnecessary parsing roundtrip in number formatting, fix locale issue
Jul 18, 2015
I can confirm this resolves #6443, thanks!
As far as I can see the output is as expected, except for the difficulty, returned by
Exactly - the fixed 8-digit formatting is for clarity in monetary amounts.
If i understand this right, then there is a slightly API change. Every double/float (non-monetary) comes now with a precision of 16 instead of 8 (because of https://github.com/bitcoin/bitcoin/pull/6456/files#diff-0f1b401041a14398229cf7e31b6db7eeR89). Because we are using
Right. All numbers were 'cut' to %.8f notation, so it would have reported