Repository navigation
OnixLabs.Numerics.BigDecimalEqualityComparer
Provides equality comparison for BigDecimal 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, and all user-defined strategies are served through the comparer parameter overloads on BigDecimal.
| Namespace | OnixLabs.Numerics |
| Assembly | OnixLabs.Numerics.dll (NuGet) |
| Inheritance |
object → BigDecimalEqualityComparer
|
| Implements |
IEqualityComparer<BigDecimal>, IEqualityComparer
|
public abstract class BigDecimalEqualityComparer : IEqualityComparer<BigDecimal>, IEqualityComparerBigDecimalEqualityComparer is the abstract base for 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 BigDecimal.Equals(BigDecimal, BigDecimalEqualityComparer) or the static BigDecimal.Equals(BigDecimal, BigDecimal, BigDecimalEqualityComparer) to select the comparison strategy explicitly. The instance Equals(BigDecimal) and GetHashCode() members on BigDecimal always use Strict.
| Member | Type | Description |
|---|---|---|
Strict |
BigDecimalEqualityComparer |
Compares both UnscaledValue and Scale; 1.20 ≠ 1.2. |
Semantic |
BigDecimalEqualityComparer |
Compares by numeric value only; 1.20 == 1.2. |
public static readonly BigDecimalEqualityComparer Strict;An equality comparer that requires both UnscaledValue and Scale to be identical. Used by BigDecimal.Equals(BigDecimal), BigDecimal.GetHashCode(), and BigDecimal.Equals(BigDecimal, BigDecimal).
public static readonly BigDecimalEqualityComparer Semantic;An equality comparer that considers two BigDecimal values equal when they represent the same numeric value, regardless of scale. Used by operator == and operator !=.
| Method | Returns | Description |
|---|---|---|
Equals(BigDecimal, BigDecimal) |
bool |
Determines whether two BigDecimal values are equal. |
GetHashCode(BigDecimal) |
int |
Returns a hash code for the specified BigDecimal value. |
Equals(object?, object?) |
bool |
Determines whether two objects are equal. |
GetHashCode(object) |
int |
Returns a hash code for the specified object. |
public abstract bool Equals(BigDecimal x, BigDecimal y)Determines whether the two specified BigDecimal values are equal according to the comparer's strategy.
| Parameter | Type | Description |
|---|---|---|
x |
BigDecimal |
The first value to compare. |
y |
BigDecimal |
The second value to compare. |
Returns — true if the values are equal; otherwise, false.
public abstract int GetHashCode(BigDecimal obj)Returns a hash code for the specified BigDecimal value, consistent with the comparer's equality strategy.
| Parameter | Type | Description |
|---|---|---|
obj |
BigDecimal |
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 the two specified objects are equal. Returns true only when both x and y are BigDecimal values that are equal under this comparer's strategy.
Returns — true if both are equal BigDecimal values; otherwise, false.
public int GetHashCode(object obj)Returns a hash code for the specified object. Delegates to GetHashCode(BigDecimal) when obj is a BigDecimal; otherwise delegates to object.GetHashCode().
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