Use Number for IOUAmount and STAmount arithmetic

* Guarded by amendment fixUniversalNumber
* Produces slightly better accuracy in some computations.
This commit is contained in:
Howard Hinnant
2022-06-01 15:51:00 -04:00
committed by Elliot Lee
parent 48e804c40c
commit a82ad5ba76
14 changed files with 233 additions and 222 deletions

View File

@@ -2122,7 +2122,7 @@ public:
jrr = ledgerEntryState(env, bob, gw, "USD");
BEAST_EXPECT(
jrr[jss::node][sfBalance.fieldName][jss::value] ==
"-0.966500000033334");
"-0.9665000000333333");
}
void

View File

@@ -905,6 +905,7 @@ public:
{
testcase("IOU to IOU");
NumberSO stNumberSO{true};
Quality q1 = get_quality("1", "1");
// Highly exaggerated 50% transfer rate for the input and output:
@@ -937,7 +938,7 @@ public:
q1,
{"4", "4"},
"4",
{"2.666666666666666", "2.666666666666666"},
{"2.666666666666667", "2.666666666666667"},
eur(),
usd(),
rate,
@@ -993,7 +994,7 @@ public:
q1,
{"2", "2"},
"10",
{"1.666666666666666", "1.666666666666666"},
{"1.666666666666667", "1.666666666666667"},
eur(),
usd(),
rate,

View File

@@ -411,13 +411,11 @@ class TrustAndBalance_test : public beast::unit_test::suite
if (with_rate)
{
// 65.00000000000001 is correct.
// This is result of limited precision.
env.require(balance(
alice,
STAmount(
carol["USD"].issue(),
6500000000000001ull,
6500000000000000ull,
-14,
false,
true,