Decimal.opBinary

Calculate other price.

  1. Decimal opBinary(const(Decimal) rhs)
    struct Decimal
    const @nogc nothrow pure
    opBinary
    (
    string op
    )
    (
    auto scope ref const(Decimal) rhs
    )
    if (
    op == "+" ||
    op == "-"
    )
  2. Decimal opBinary(long rhs)
  3. Decimal opBinary(const(Decimal) rhs)

Parameters

rhs const(Decimal)

other hand price.

Return Value

Type: Decimal

calculated price.

Examples

immutable a = Decimal(123000, 3);
immutable b = Decimal(456, 3);
assert(a + b == Decimal(123456, 3));
assert(a - b == Decimal(122544, 3));

immutable c = Decimal(-456, 3);
assert(a + c == Decimal(122544, 3));
assert(a - c == Decimal(123456, 3));

assert(b - a == Decimal(-122544, 3));

Meta