-
Notifications
You must be signed in to change notification settings - Fork 3
currency wire format #20
Comments
A good way of testing implementations of binary parsing/reading is to implement a ShaMap and download some ledgers, calculating the transaction_hash. You can retrieve the transactions in binary form from rippled. |
Ah! That would explain why the C++ code iterates *10 and /10 to make the sublimator: If we read the TX from the binary fromat, it actually computes Thank you to both of you for this, Philippe On Wed, Feb 26, 2014 at 1:45 PM, sublimator notifications@github.comwrote:
|
You can load from the rippled json too (for sanity testing) |
Actually a guy on the ripple forum posted a heap of full ledgers |
BinarySerializer, write currency.
Your code is correct but ripple rejects "floating point" values whose mantissa doesn't have 16 digits.
Lets say I want to send the value 1.23.
Instead of the way you would expect.
mantissa = 123; // unscaled value
scale = 2; // or negative 2 in some implementations.
ripple expects it to be in wire format
mantissa = 1230000000000000;
scale = 15; // again may be -15
Both values are equal but only the second is accepted by rippled
1230000000000000 * 10 ^ -15 == 123 * 10 ^ -3; // statement is true
This is why the max and min scale have a difference of 16
80 - 96 = 16.
and is also why 54 bits is allocated for the mantissa
9999999999999999 // 54 bit number.
It took me three days to figure out why your code was correct but returning "invalid currency value"
The text was updated successfully, but these errors were encountered: