Skip to content

OnixLabs.Numerics.ScaleMode

matthew edited this page May 26, 2026 · 1 revision

ScaleMode Enum

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)

Definition

public enum ScaleMode

Fields

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.

Remarks

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.

See Also

ONIXLabs .NET Library


Clone this wiki locally