Repository navigation
OnixLabs.Numerics.NumberInfoEqualityComparer
Represents an abstract base class for equality comparers that compare NumberInfo values. Two concrete strategies are available as static fields: Strict and Semantic. The class is abstract with a private constructor; the only instances are the two pre-built fields.
| Namespace | OnixLabs.Numerics |
| Assembly | OnixLabs.Numerics.dll (NuGet) |
| Inheritance |
object → NumberInfoEqualityComparer
|
| Implements |
IEqualityComparer<NumberInfo>, IEqualityComparer
|
public abstract class NumberInfoEqualityComparer : IEqualityComparer<NumberInfo>, IEqualityComparerNumberInfoEqualityComparer is the abstract base for the two built-in equality strategies. The constructor is private, so only the two pre-built instances (Strict and Semantic) are available; the class cannot be subclassed externally.
Pass an instance to NumberInfo.Equals(NumberInfo, NumberInfoEqualityComparer) or the static NumberInfo.Equals(NumberInfo, NumberInfo, NumberInfoEqualityComparer) to select the comparison strategy explicitly.
-
Strict — two values are equal only when both
UnscaledValueandScaleare identical. The hash code combinesUnscaledValueandScale. -
Semantic — two values are equal when they represent the same mathematical quantity, regardless of trailing zeros or scale. Equality is delegated to
NumberInfoOrdinalityComparer.Default. The hash code combinesSignificandandExponent.
| Member | Type | Description |
|---|---|---|
Strict |
NumberInfoEqualityComparer |
An equality comparer that compares both UnscaledValue and Scale. |
Semantic |
NumberInfoEqualityComparer |
An equality comparer that treats numerically equivalent values as equal regardless of scale. |
public static readonly NumberInfoEqualityComparer Strict;A NumberInfoEqualityComparer that strictly compares NumberInfo values, including their scale. Two values are equal only when both UnscaledValue and Scale are identical. The hash code combines UnscaledValue and Scale.
public static readonly NumberInfoEqualityComparer Semantic;A NumberInfoEqualityComparer that semantically compares NumberInfo values, treating numerically equivalent values as equal regardless of scale. Equality is determined by NumberInfoOrdinalityComparer.Default. The hash code combines Significand and Exponent.
| Method | Returns | Description |
|---|---|---|
Equals(NumberInfo, NumberInfo) |
bool |
Determines whether two NumberInfo values are equal (abstract). |
GetHashCode(NumberInfo) |
int |
Returns a hash code for a NumberInfo value (abstract). |
Equals(object?, object?) |
bool |
Determines whether two objects are equal NumberInfo values. |
GetHashCode(object) |
int |
Returns a hash code for an object. |
public abstract bool Equals(NumberInfo x, NumberInfo y)Determines whether two NumberInfo values are equal according to the concrete comparer's strategy.
| Parameter | Type | Description |
|---|---|---|
x |
NumberInfo |
The first value to compare. |
y |
NumberInfo |
The second value to compare. |
Returns — true if x and y are equal; otherwise, false.
public abstract int GetHashCode(NumberInfo obj)Returns a hash code for the specified NumberInfo value according to the concrete comparer's strategy.
| Parameter | Type | Description |
|---|---|---|
obj |
NumberInfo |
The value for which to compute a hash code. |
Returns — A 32-bit signed integer hash code.
public new bool Equals(object? x, object? y)Determines whether two objects are equal. Returns true only when both x and y are NumberInfo values that are equal according to the concrete comparer's strategy.
| Parameter | Type | Description |
|---|---|---|
x |
object? |
The first object to compare. |
y |
object? |
The second object to compare. |
Returns — true if both objects are NumberInfo values that are equal; otherwise, false.
public int GetHashCode(object obj)Returns a hash code for the specified object. When obj is a NumberInfo value, delegates to GetHashCode(NumberInfo); otherwise falls back to object.GetHashCode().
| Parameter | Type | Description |
|---|---|---|
obj |
object |
The object for which to compute a hash code. |
Returns — A 32-bit signed integer hash code.
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