Repository navigation
OnixLabs.Numerics.ScaleMode
Specifies decimal scale modes that control how an integer value is positioned relative to the decimal point when converting to a scaled numeric type.
| Namespace | OnixLabs.Numerics |
| Assembly | OnixLabs.Numerics.dll (NuGet) |
public enum ScaleMode| Name | Value | Description |
|---|---|---|
Fractional |
0 |
Specifies that unscaled values should be preserved; for example, 123 with a scale of 10 becomes 0.0000000123. |
Integral |
1 |
Specifies that integer values should be preserved; for example, 123 with a scale of 10 becomes 123.0000000000. |
When converting an integer value to a scaled decimal type such as BigDecimal or decimal, ScaleMode determines how the scale is applied.
Fractional (default) — The raw unscaled significand is preserved as-is; the scale merely defines where the decimal point sits. Supplying the integer 123 with a scale of 10 produces 0.0000000123 — the digit sequence 123 is placed 10 positions to the right of the decimal point. Use this mode when the integer argument already represents an unscaled significand, for example when constructing a BigDecimal from a stored database integer that encodes a fixed-point value.
Integral — The numeric value of the integer is preserved; the scale adds trailing fractional zeros. Supplying the integer 123 with a scale of 10 produces 123.0000000000. Use this mode when the integer represents a whole number and you want the result to carry a specific number of decimal places, for example when formatting a currency amount.
ScaleMode is consumed by the following overloads in NumericsExtensions:
ToBigDecimal<T>(this T, int, ScaleMode)ToDecimal<T>(this T, int, ScaleMode)ToNumberInfo<T>(this T, int, ScaleMode)
The default value of ScaleMode is Fractional (field value 0), so calling any of these overloads without specifying a mode selects fractional scaling.
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