Decimal.opOpAssign

struct Decimal(size_t maxSize64)
ref @safe pure return
opOpAssign
(
string op
size_t rhsMaxSize64
)
(
ref const Decimal!rhsMaxSize64 rhs
)
if (
op == "+" ||
op == "-"
)
if (
maxSize64 &&
maxSize64 <= ushort.max
)

Examples

import std.stdio;
auto a = Decimal!1("777.7");
auto b = Decimal!1("777");
import mir.format;
assert(stringBuf() << cast(double)a - cast(double)b << getData == "0.7000000000000455");
a -= b;
assert(stringBuf() << a << getData == "0.7");

a = Decimal!1("-777.7");
b = Decimal!1("777");
a += b;
assert(stringBuf() << a << getData == "-0.7");

a = Decimal!1("777.7");
b = Decimal!1("-777");
a += b;
assert(stringBuf() << a << getData == "0.7");

a = Decimal!1("777");
b = Decimal!1("777.7");
a -= b;
assert(stringBuf() << a << getData == "-0.7");

Meta