0
after reading bitcoin wiki "Proper money handling" I supposed that there shouldn't be any precision problems.
However, sending/moving for instance 16999999.99999999 sends/moves 17000000.
I figured out where the problem is:
- PHP stores float value with sufficient precision. I can printf it with 8 correct digits after dot.
- json-rpc php library copies that float into "params" array, and again, precision is fine.
- Unfortunately, string produced by json_encode() used in json-rpc library contains "rounded" value, so there is a problem.
So, can I force json_encode() to output 8 digits (or more)? Or do I have to write my own, which isn't very complicated, but will be rather slower than standard function.
Please note those topics about problems with floats in PHP and Python on bitcointalk, so it is not my fault. One of the results of this issue is genjix branch of bitcoin, that sends amounts as strings.
Best wishes
I see JSON-RPC PHP recommended on the Bitcoin wiki, have you tried swapping that in?
– Nick ODell – 2013-07-29T19:04:12.100Well, I'm using that library, but I was trying to use others, too. But it is problem with json_encode(), which is PHP function, not a library function. This function is used in nearly all libraries, so it doesn't help. – ripazha – 2013-07-30T08:14:59.020
Just use the string format with "%.8f" – Justin – 2014-04-05T01:58:51.107