Repository navigation
OnixLabs.Numerics.ConversionMode
Specifies IEEE 754 binary floating-point conversion modes used when converting float, double, Float128, and Float256 values to BigDecimal or NumberInfo.
| Namespace | OnixLabs.Numerics |
| Assembly | OnixLabs.Numerics.dll (NuGet) |
public enum ConversionMode| Name | Value | Description |
|---|---|---|
Decimal |
0 |
Specifies that IEEE 754 binary floating-point values will be converted from their decimal representation. |
Binary |
1 |
Specifies that IEEE 754 binary floating-point values will be converted from their binary representation. |
IEEE 754 binary floating-point types such as float and double can be interpreted in two distinct ways when converting to a decimal numeric type, and ConversionMode selects between them.
Decimal (default) — The value is converted from its shortest-round-trip decimal string representation. For example, 0.1f converts to exactly 0.1, because "0.1" is the shortest decimal string that round-trips back to that float. This is typically what application code wants, and it matches the decimal value a developer typed in source.
Binary — The value is converted from its exact IEEE 754 binary representation, including any representation error introduced by the binary encoding. For example, 0.1f converts to approximately 0.100000001490116119384765625, because that is the exact rational value stored in the 32-bit float. Use this mode when you need the mathematically exact stored value, for example in numerical analysis or when comparing bit-identical representations.
ConversionMode is consumed by the following overloads in NumericsExtensions:
ToBigDecimal(this float, ConversionMode)ToBigDecimal(this double, ConversionMode)ToNumberInfo(this float, ConversionMode)ToNumberInfo(this double, ConversionMode)ToNumberInfo(this Float128, ConversionMode)ToNumberInfo(this Float256, ConversionMode)
The default value of ConversionMode is Decimal (field value 0), so calling any of these overloads without specifying a mode selects the decimal interpretation.
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