🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Precision
This page was created by Henrik on 2020-08-21. Last edited by Wikiadmin on 2026-07-29.

You can control the database size and decimal-place capacity of a class attribute by setting its Precision, Scale, and, where applicable, Length in the Property Inspector.

Configure an attribute

  1. Select the class attribute in MDriven Designer.
  2. In the Property Inspector, locate Precision, Scale, and Length.
  3. For a Decimal attribute, set both Precision and Scale when you need a database-specific decimal definition.
  4. Evolve or update the persistence mapping so that the database schema reflects the changed attribute settings.

These settings are managed through the database mapping. Their resulting Transact-SQL definition follows SQL Server rules.

Precision and Scale

Precision is the total number of digits that a decimal value can contain. Scale is the number of digits to the right of the decimal separator.

For example, an attribute with Precision = 10 and Scale = 2 can hold values such as 12345.67 and 0.12. The total digit capacity is 10, and two of those digits are reserved for the fractional part.

Setting Meaning Example
Precision Total number of digits in the value Precision 38 allows up to 38 digits in total.
Scale Number of digits after the decimal separator Scale 4 stores four decimal places, such as 12.3456.
Precision 38, Scale 4 A 38-digit decimal number with four fractional digits 1234567890123456789012345678901234.5678

On SQL Server, Decimal is stored by default with 38 digits including 2 decimal places. Set Scale to change the number of decimal places, and set Precision to control the total number of digits.

Important: set both values

Set both Precision and Scale to values other than -1. If either setting remains -1, neither setting is used.

For example, to map an amount with four decimal places, set Precision to 38 and Scale to 4; do not set only Scale to 4 while leaving Precision at -1.

Length

Length is also an attribute setting used by persistence mapping. The generated mapping carries Length, Scale, and Precision as column metadata. For example, a mapped text column can have Length="255", while decimal-related settings use Scale and Precision.

Use Length according to the Transact-SQL requirements of the mapped column type. Review the generated mapping when you need to verify the resulting column metadata; see Documentation:Working with Code and Persistence Mapping.

Choose the appropriate numeric type

Use Decimal when a value must retain exact decimal places, such as money, tax, or quantities that require precise decimal calculation. Do not use floating-point types as a substitute when exact decimal representation is required: Float and Double can have floating-point approximation effects.

Changing a value between numeric types can also change its precision or discard fractions. For conversion syntax and examples in OCL and EAL, see Number conversions.

Storage precision and displayed precision

Precision and Scale define storage-related attribute metadata. They do not by themselves define how many decimal places users see in a client UI.

For example, an amount may be stored with Scale 4 as 12.3456, while a UI format displays it with two decimal places. For WPF ViewModel formatting, see Documentation:Styling WPF Applications and ViewModels. For culture-specific number rendering and the default decimal display setting, see Documentation:Localization.

See also

[[Category:Attributes and data types [Beginner]]]