Talk:Proper Money Handling (JSON-RPC): Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
RE: best practices in ECMAScript: | |||
Just converting to base units doesn't magically fix the issues; if I have 1.0BTC == 100000000.0 base units and I need to divide that value into three equal pieces, I'm going to run into issues whether the result is 0.3333333.... or 3333333.33333... | |||
And the fixes are the same: either round to the nearest .0000001 or to the nearest 1 before display, etc. | |||
For Ruby I think the syntax is: | |||
(f * 1e8).round.to_f / 1e8 | |||
Correct? | |||
== ECMAScript? == | |||
Since the value is already in ECMAScript's native representation, why would you use a conversion function? | |||
* The RPC value is passed as an inexact floating point. Money handling should always be done as integers. --[[User:Luke-jr|Luke-jr]] 00:57, 11 June 2011 (GMT) |
Latest revision as of 00:57, 11 June 2011
RE: best practices in ECMAScript: Just converting to base units doesn't magically fix the issues; if I have 1.0BTC == 100000000.0 base units and I need to divide that value into three equal pieces, I'm going to run into issues whether the result is 0.3333333.... or 3333333.33333...
And the fixes are the same: either round to the nearest .0000001 or to the nearest 1 before display, etc.
For Ruby I think the syntax is:
(f * 1e8).round.to_f / 1e8
Correct?
ECMAScript?
Since the value is already in ECMAScript's native representation, why would you use a conversion function?
- The RPC value is passed as an inexact floating point. Money handling should always be done as integers. --Luke-jr 00:57, 11 June 2011 (GMT)