Loading

Currency and Number Fields Round When There Are More Than 15 Characters to the Left or Right of the Decimal

Дата публикации: Jun 18, 2026
Описание

Overview

Currency and number fields in Salesforce may round unexpectedly when the field length is set to 16 or more characters to the left or right of the decimal point with 2 decimal places. This rounding can also occur in whole number fields where the numeric value is longer than 15 digits.

Examples of Affected Values

The following examples show how values round when they exceed 15 significant digits:

  • 1,222,333,444,555,666.88 becomes 1,222,333,444,555,667
  • 1,222,333,444,555,666.84 becomes 1,222,333,444,555,666.80
  • 1,222,333,444,555,666.56 becomes 1,222,333,444,555,666.50
  • 1,222,333,444,555,666.35 becomes 1,222,333,444,555,666.20
  • 1,222,333,444,555,666.12 becomes 1,222,333,444,555,666
  • 49.9999999999999972 becomes 50
  • 9999999999999999 becomes 10000000000000000

These rounding behaviors occur with currency or number fields configured with 16 or more digits on either side of the decimal, or whole number fields with more than 15 digits.

Why This Happens

JavaScript uses double-precision 64-bit floating-point numbers (IEEE 754 standard), which can only accurately represent integers up to 2^53 (approximately 9 quadrillion, or 9,007,199,254,740,992). Numbers larger than this threshold lose precision when processed in JavaScript.
Since Salesforce's Lightning Experience UI uses JavaScript to render field values, any number exceeding this threshold is subject to rounding when displayed or edited in the browser. This is a JavaScript platform limitation and is not specific to Salesforce — the same rounding occurs in any JavaScript environment, including browser developer consoles.

 

Решение

Expected Behavior

This rounding behavior is expected and by design. It occurs in the following contexts:

  • UI in Lightning Experience: When a user views or edits a record with an affected field value
  • REST API: When values are retrieved or written via the REST API
  • Bulk API: When values are processed via the Bulk API
  • Developer Console: When entering a value in a number field in Execute Anonymous

If a user saves a record with a rounded value via the UI, the rounded value is written to the database. If any validation rules require the original unrounded value to be unchanged, the rounding may trigger a validation error.

Workaround

If your business requires precise numeric values exceeding 15 significant digits, consider the following options:

  1. Store the value as a text field and use custom validation rules to enforce the correct format and prevent unintended modifications through the UI.
  2. Write values via API only — using the Salesforce REST API or SOAP API to write values directly bypasses the JavaScript UI layer and preserves full precision at the database level. Restrict UI editing of these fields where possible.
  3. Restructure data to avoid values exceeding 15 significant digits where possible.
Дополнительные ресурсы
Номер статьи базы знаний

000394530

 
Загрузка
Salesforce Help | Article