Skip to content

OnixLabs.Numerics.BigDecimalOrdinalityComparer

matthew edited this page May 27, 2026 · 1 revision

BigDecimalOrdinalityComparer Class

Provides ordinal (ordering) comparison for BigDecimal values. The single instance is available via the Default field. Ordering is always semantic, comparing the underlying numeric values regardless of scale.

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

Definition

public sealed class BigDecimalOrdinalityComparer : IComparer<BigDecimal>, IComparer

Remarks

BigDecimalOrdinalityComparer compares BigDecimal values by their numeric value. Comparison is delegated to NumberInfoOrdinalityComparer.Default, which aligns the two values to a common scale before comparing their unscaled integers.

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

Fields

Member Type Description
Default BigDecimalOrdinalityComparer The single shared instance of the ordinal comparer.

Default

public static readonly BigDecimalOrdinalityComparer Default;

The default ordinal comparer for BigDecimal values. This is the only publicly accessible instance; the constructor is private.

Methods

Method Returns Description
Compare(BigDecimal, BigDecimal) int Compares two BigDecimal values by numeric value.
Compare(object?, object?) int Compares two objects assumed to be BigDecimal values.
IsEqual(BigDecimal, BigDecimal) bool Returns true if the two values are numerically equal.
IsGreaterThan(BigDecimal, BigDecimal) bool Returns true if left is greater than right.
IsGreaterThanOrEqual(BigDecimal, BigDecimal) bool Returns true if left is greater than or equal to right.
IsLessThan(BigDecimal, BigDecimal) bool Returns true if left is less than right.
IsLessThanOrEqual(BigDecimal, BigDecimal) bool Returns true if left is less than or equal to right.

Compare(BigDecimal, BigDecimal)

public int Compare(BigDecimal x, BigDecimal y)

Compares two BigDecimal values and returns a signed integer indicating their relative order. Delegates to NumberInfoOrdinalityComparer.Default.

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

Returns — A negative integer if x < y, zero if x == y, or a positive integer if x > y.


Compare(object?, object?)

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

Compares two objects. Both must be BigDecimal values.

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

Returns — A signed integer indicating the relative order of the two values.

Exceptions

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

IsEqual(BigDecimal, BigDecimal)

public bool IsEqual(BigDecimal left, BigDecimal right)

Returns — true if left and right are numerically equal; otherwise, false.


IsGreaterThan(BigDecimal, BigDecimal)

public bool IsGreaterThan(BigDecimal left, BigDecimal right)

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


IsGreaterThanOrEqual(BigDecimal, BigDecimal)

public bool IsGreaterThanOrEqual(BigDecimal left, BigDecimal right)

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


IsLessThan(BigDecimal, BigDecimal)

public bool IsLessThan(BigDecimal left, BigDecimal right)

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


IsLessThanOrEqual(BigDecimal, BigDecimal)

public bool IsLessThanOrEqual(BigDecimal left, BigDecimal right)

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

See Also

ONIXLabs .NET Library


Clone this wiki locally