operator % method

Obj<num> operator %(
  1. Obj<num> other
)

Euclidean modulo of this number by other.

Returns the remainder of the Euclidean division. The Euclidean division of two integers a and b yields two integers q and r such that a == b * q + r and 0 <= r < b.abs().

The Euclidean division is only defined for integers, but can be easily extended to work with doubles. In that case, q is still an integer, but r may have a non-integer value that still satisfies 0 <= r < |b|.

The sign of the returned value r is always positive.

See remainder for the remainder of the truncating division.

The result is an Obj of double, as described by double.%, if both this and other are Obj of double, otherwise the result is a Obj of int.

Example:

print(Obj(5) % Obj(3)); // Obj(2)
print(Obj(-5) % Obj(3)); // Obj(1)
print(Obj(5) % Obj(-3)); // Obj(2)
print(Obj(-5) % Obj(-3)); // Obj(1)

Implementation

Obj<num> operator %(Obj<num> other) => (value % other.value).obj;