The OpenD Programming Language

ProperCompare.hookOpEquals

Hook for == and != that ensures comparison against integral values has the behavior expected by the usual arithmetic rules. The built-in semantics yield surprising behavior when comparing signed values against unsigned values for equality, for example uint.max == -1 or -1_294_967_296 == 3_000_000_000u. The call hookOpEquals(x, y) returns true if and only if x and y represent the same arithmetic number.

If one of the numbers is an integral and the other is a floating-point number, hookOpEquals(x, y) returns true if and only if the integral can be converted exactly (without approximation) to the floating-point number. This is in order to preserve transitivity of equality: if hookOpEquals(x, y) and hookOpEquals(y, z) then hookOpEquals(y, z), in case x, y, and z are a mix of integral and floating-point numbers.

struct ProperCompare
static
bool
hookOpEquals
(
L
R
)
(
L lhs
,
R rhs
)

Parameters

lhs L

The left-hand side of the comparison for equality

rhs R

The right-hand side of the comparison for equality

Return Value

Type: bool

The result of the comparison, true if the values are equal

Meta