Decimal.opCmp

Compare two prices.

struct Decimal
const @nogc nothrow pure scope
int
opCmp
()
(
auto ref const(Decimal) other
)

Parameters

other const(Decimal)

other price number.

Return Value

Type: int

opCmp result.

Examples

immutable a = Decimal(123456, 3);
assert(!(a < a));
assert(!(a > a));
assert(a <= a);
assert(a >= a);

immutable b = Decimal(123457, 3);
assert(a < b);
assert(a <= b);
assert(!(a > b));
assert(!(a >= b));

assert(b > a);
assert(b >= a);
assert(!(b < a));
assert(!(b <= a));

immutable c = Decimal(1234560, 4);
assert(!(a < c));
assert(!(a > c));
assert(a <= c);
assert(a >= c);

assert(!(c < a));
assert(!(c > a));
assert(c <= a);
assert(c >= a);

immutable d = Decimal(1234561, 4);
assert(a < d);
assert(!(a > d));
assert(a <= d);
assert(!(a >= d));

assert(!(d < a));
assert(d > a);
assert(!(d <= a));
assert(d >= a);
immutable a = Decimal(1234559, 4); // 123.4559
immutable b = Decimal(123456, 3); // 123.456
assert(a < b);
assert(a <= b);
assert(!(b < a));

assert(b > a);
assert(b >= a);
assert(!(a > b));

Meta