Skip to content

OnixLabs.Numerics.NumberInfoOrdinalityComparer

matthew edited this page May 27, 2026 · 1 revision

NumberInfoOrdinalityComparer Class

Represents a sealed comparer for ordering NumberInfo values by their numeric magnitude. The single instance is available via the Default field.

Namespace OnixLabs.Numerics
Assembly OnixLabs.Numerics.dll (NuGet)
Inheritance object → NumberInfoOrdinalityComparer
Implements IComparer<NumberInfo>, IComparer

Definition

public sealed class NumberInfoOrdinalityComparer : IComparer<NumberInfo>, IComparer

Remarks

NumberInfoOrdinalityComparer compares NumberInfo values by their numeric value. When the two values have different signs, the sign difference determines the order outright. When they share the same sign, the values are aligned to a common scale by multiplying the value with the smaller scale by the appropriate power of ten, and their unscaled integers are then compared directly.

The constructor is private; the only available instance is Default.

Fields

Member Type Description
Default NumberInfoOrdinalityComparer The default ordinal comparer for NumberInfo values.

Default

public static readonly NumberInfoOrdinalityComparer Default;

The single pre-built instance of NumberInfoOrdinalityComparer. Used internally by NumberInfo.CompareTo, NumberInfo.Compare, and all comparison operators, as well as by BigDecimalOrdinalityComparer.

Methods

Method Returns Description
Compare(NumberInfo, NumberInfo) int Compares two NumberInfo values and returns their relative order.
Compare(object?, object?) int Compares two objects as NumberInfo values.
IsEqual(NumberInfo, NumberInfo) bool Determines whether two NumberInfo values are numerically equal.
IsGreaterThan(NumberInfo, NumberInfo) bool Determines whether the left value is greater than the right value.
IsGreaterThanOrEqual(NumberInfo, NumberInfo) bool Determines whether the left value is greater than or equal to the right value.
IsLessThan(NumberInfo, NumberInfo) bool Determines whether the left value is less than the right value.
IsLessThanOrEqual(NumberInfo, NumberInfo) bool Determines whether the left value is less than or equal to the right value.

Compare(NumberInfo, NumberInfo)

public int Compare(NumberInfo x, NumberInfo y)

Compares two NumberInfo values and returns a signed integer indicating their relative order.

Parameter Type Description
x NumberInfo The first value to compare.
y NumberInfo The second value to compare.

Returns — A negative integer if x precedes y, zero if they are equal, or a positive integer if x follows y.


Compare(object?, object?)

public int Compare(object? x, object? y)

Compares two objects as NumberInfo values.

Parameter Type Description
x object? The first object to compare.
y object? The second object to compare.

Returns — A negative integer if x precedes y, zero if they are equal, or a positive integer if x follows y.

Exceptions

Exception Condition
ArgumentException x or y is not of type NumberInfo.

IsEqual(NumberInfo, NumberInfo)

public bool IsEqual(NumberInfo left, NumberInfo right)

Determines whether left and right are numerically equal. Equivalent to Compare(left, right) == 0.

Parameter Type Description
left NumberInfo The left value to compare.
right NumberInfo The right value to compare.

Returns — true if the values are numerically equal; otherwise, false.


IsGreaterThan(NumberInfo, NumberInfo)

public bool IsGreaterThan(NumberInfo left, NumberInfo right)

Determines whether left is numerically greater than right. Equivalent to Compare(left, right) > 0.

Parameter Type Description
left NumberInfo The left value to compare.
right NumberInfo The right value to compare.

Returns — true if left is greater than right; otherwise, false.


IsGreaterThanOrEqual(NumberInfo, NumberInfo)

public bool IsGreaterThanOrEqual(NumberInfo left, NumberInfo right)

Determines whether left is numerically greater than or equal to right. Equivalent to Compare(left, right) >= 0.

Parameter Type Description
left NumberInfo The left value to compare.
right NumberInfo The right value to compare.

Returns — true if left is greater than or equal to right; otherwise, false.


IsLessThan(NumberInfo, NumberInfo)

public bool IsLessThan(NumberInfo left, NumberInfo right)

Determines whether left is numerically less than right. Equivalent to Compare(left, right) < 0.

Parameter Type Description
left NumberInfo The left value to compare.
right NumberInfo The right value to compare.

Returns — true if left is less than right; otherwise, false.


IsLessThanOrEqual(NumberInfo, NumberInfo)

public bool IsLessThanOrEqual(NumberInfo left, NumberInfo right)

Determines whether left is numerically less than or equal to right. Equivalent to Compare(left, right) <= 0.

Parameter Type Description
left NumberInfo The left value to compare.
right NumberInfo The right value to compare.

Returns — true if left is less than or equal to right; otherwise, false.

See Also

ONIXLabs .NET Library


Clone this wiki locally