Repository navigation
OnixLabs.Numerics.NumberInfoOrdinalityComparer
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
|
public sealed class NumberInfoOrdinalityComparer : IComparer<NumberInfo>, IComparerNumberInfoOrdinalityComparer 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.
| Member | Type | Description |
|---|---|---|
Default |
NumberInfoOrdinalityComparer |
The default ordinal comparer for NumberInfo values. |
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.
| 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. |
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.
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. |
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.
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.
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.
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.
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.
ONIXLabs .NET Library · Repository · NuGet · License (Apache-2.0)
Copyright © ONIXLabs 2020. Licensed under the Apache License, Version 2.0.
- Enumeration<T>
- Optional<T>
- OptionalEqualityComparer<T>
- OptionalExtensions
- Result
- Result<T>
- ResultEqualityComparer<T>
- ResultExtensions
- Specification<T>
- Preconditions
- IValueEquatable<T>
- IValueComparable<T>
- IBinaryConvertible
- ISpanBinaryConvertible
- IMemoryBinaryConvertible
- ArrayExtensions
- ComparableExtensions
- DateTimeExtensions
- ISpanParsableExtensions
- ObjectExtensions
- RandomExtensions
- ReadOnlySequenceExtensions
- ReadOnlySpanExtensions
- StringExtensions
- Base16
- Base32
- Base58
- Base64
- IBaseCodec
- IBaseValue
- IBaseValue<T>
- Base16Codec
- Base32Codec
- Base58Codec
- Base64Codec
- Base16FormatProvider
- Base32FormatProvider
- Base58FormatProvider
- Base64FormatProvider
- EncodingExtensions
- ReadOnlySpanExtensions
- StringBuilderExtensions
- BigDecimal
- BigDecimalEqualityComparer
- BigDecimalOrdinalityComparer
- NumberInfo
- NumberInfoEqualityComparer
- NumberInfoOrdinalityComparer
- Int256
- Int512
- UInt256
- UInt512
- Float128
- Float256
- GenericMath
- NumericsExtensions
- ConversionMode
- ScaleMode
- Hash
- NamedHash
- Sha3
- Sha3Hash224
- Sha3Hash256
- Sha3Hash384
- Sha3Hash512
- Sha3Shake128
- Sha3Shake256
- MerkleTree
- MerkleTree<T>
- PrivateKey
- PublicKey
- NamedPrivateKey
- NamedPublicKey
- EcdhPrivateKey
- EcdhPublicKey
- EcdsaPrivateKey
- EcdsaPublicKey
- EddsaPrivateKey
- EddsaPublicKey
- RsaPrivateKey
- RsaPublicKey
- DigitalSignature
- DigitalSignatureAndPublicKey
- Salt
- Secret
- ICryptoPrimitive<T>
- IHashable
- IEcdhPrivateKey
- IEcdsaPrivateKey
- IEddsaPrivateKey
- IRsaPrivateKey
- IPrivateKeyDerivable<T>
- IPrivateKeyExportable
- IPrivateKeyImportable<T>
- IPrivateKeyPemImportable<T>
- IPrivateKeyPkcs8Exportable
- IPrivateKeyPkcs8Importable<T>
- IPrivateKeyPkcs8PemExportable
- IPrivateKeyRawExportable
- IPrivateKeyRawImportable<T>
- IPrivateKeyRawPemExportable
- IEcdhPublicKey
- IEcdsaPublicKey
- IEddsaPublicKey
- IRsaPublicKey
- IPublicKeyExportable
- IPublicKeyImportable<T>
- IPublicKeyPemExportable
- IPublicKeyPemImportable<T>
- IPublicKeyRawExportable
- IPublicKeyRawImportable<T>
- HashAlgorithmExtensions
- ReadOnlySpanExtensions