XLS Number Precision: Why Long IDs and Decimal Values Change

November 08, 2026 · XLS.now Editorial · XLS Troubleshooting

Explain 15-digit precision, display formats, text import and validation for IDs and finance data.

The 15-Digit Precision Limit in XLS Binary Storage

The XLS binary format stores every numeric cell value as an 8-byte IEEE 754 double-precision floating-point number. This representation provides approximately 15 significant decimal digits of precision. The format specification [MS-XLS] Section 2.5.1 defines the NUMBER record (record type 515) as containing an 8-byte IEEE 754 double, and the RK record (record type 638) as storing a compressed 4-byte or 8-byte floating-point value. Neither record type supports arbitrary-precision integers, fixed-point decimals, or string-encoded numbers.

When a value exceeds 15 significant digits—such as the 20-digit integer 12345678901234567890—the IEEE 754 representation rounds it to the nearest representable value. The stored value becomes 12345678901234500000. The last five digits are discarded at write time, not during display or export. This is a lossy conversion that occurs inside the XLS writer, not a rendering artifact.

Observable check: Open the XLS file in a hex editor or a tool that reads raw cell records. Locate the NUMBER record for the cell. The 8 bytes contain the IEEE 754 encoding of 12345678901234500000, not the original 20-digit integer. No hidden metadata preserves the discarded digits.

How Display Formatting Obscures Truncation

Excel and other spreadsheet applications apply default number formatting that can mask precision loss. A cell containing the truncated value 12345678901234500000 may display as 1.23457E+19 when the column width is insufficient. Widening the column reveals 12345678901234500000, which appears intact but is not.

The formula bar shows the stored value, not the original input. If the formula bar displays 1.23457E+19, the value is already truncated. If it displays 12345678901234500000, the value is still truncated—the trailing zeros replace the original digits.

Procedure to distinguish display from data loss:

  1. Select the cell and copy its contents.
  2. Paste into a plain text editor (Notepad, Vim, TextEdit in plain-text mode).
  3. Compare the pasted string to the original value. If digits are missing or replaced by zeros, the loss is permanent.
  4. In Excel, apply the formula =LEN(INT(ABS(A1))) to count integer digits. A result of 16 or higher confirms that the stored value exceeds the 15-digit safe threshold.

Limitation: Changing the number format to 0 or # does not restore lost digits. The format string stored in the XLS file (referenced by the format index in the NUMBER record) controls only display rendering, not the underlying binary value.

Importing Long Identifiers as Text

The only reliable method to preserve identifiers longer than 15 digits in XLS is to store them as text strings, not numbers. Text cells use the LABELSST or LABEL record types, which store character data without numeric conversion.

Step-by-step CSV import with text column typing:

  1. Open Excel and select File > Open. Navigate to the CSV file.
  2. In the file type dropdown, select Text Files (*.txt; *.csv).
  3. The Text Import Wizard appears. Select Delimited and click Next.
  4. Check the appropriate delimiter (comma, tab, or other). Click Next.
  5. In the data preview, click the column containing long IDs. Select the Text radio button under "Column data format." Repeat for each ID column.
  6. Click Finish. Save the workbook as .xls.

Verification after import:

  • The cell should display the full ID left-aligned.
  • A green triangle may appear in the corner (error checking: "Number stored as text").
  • The formula bar shows the full ID, possibly prefixed with a single quote ('). The quote is a text prefix marker, not part of the stored string.
  • Use =ISTEXT(A1) to confirm the cell contains text. A TRUE result confirms text storage.

Explicit limitation: If the source CSV already contains truncated values (e.g., 1.23E+19), importing as text preserves the truncated string. The original digits are lost in the source file and cannot be recovered by any import method.

Decimal Rounding Errors from Binary Representation

Decimal fractions such as 0.56 have no exact finite representation in binary floating-point. The XLS NUMBER record stores the closest IEEE 754 approximation. The value 1234.56 becomes 1234.5599999999999... internally. This error accumulates across arithmetic operations.

When rounding errors cause observable failure:

  • Summing a column of 10,000 currency values may produce a total off by one cent.
  • Logical comparisons (=IF(A1=B1, ...)) may return FALSE for cells that appear equal when formatted to two decimal places.
  • Exporting to CSV writes the full binary approximation, not the displayed value.

Detection procedure:

  1. Select the cell and apply a number format with 15 decimal places.
  2. If the display shows trailing digits such as 1234.5599999999999, the value is an approximation.
  3. Use =A1-ROUND(A1,2) to measure the deviation. A non-zero result confirms imprecision.
  4. For calculations, wrap values in =ROUND(A1,2) to force two-decimal-place precision before summing.

What cannot be recovered: The exact decimal value 1234.56 does not exist in the XLS file. No format change, conversion, or repair tool can reconstruct it. The XLS format provides no decimal fixed-point data type. Applications requiring exact decimal arithmetic must use formats or libraries that implement base-10 storage, such as XLSX with appropriate cell types or a database with DECIMAL column definitions.

Validating an Existing Workbook for Precision Loss

Before relying on an XLS file containing long identifiers or financial data, run these checks on the active worksheet.

ID length scan:

=IF(LEN(INT(ABS(A1)))>15, "PRECISION LOST", "OK")

Apply this formula to a helper column and filter for "PRECISION LOST." Every flagged cell contains an integer that exceeds the 15-digit safe threshold and has been rounded.

Decimal integrity test:

For a cell expected to hold a value with two decimal places, use:

=A1-ROUND(A1,2)

A non-zero result (e.g., -1.13687E-13) indicates binary floating-point error. The cell does not contain the exact decimal value.

Scientific notation search:

Press Ctrl+F, search for E+ and E-. Each match identifies a number that Excel has rendered in scientific notation, typically because it exceeds 15 significant digits or the column width forces abbreviated display. Inspect each match in the formula bar to determine whether the underlying value is truncated.

Text vs. number check:

Select a column of identifiers. Right-aligned cells without a leading quote in the formula bar are stored as numbers. If the identifier exceeds 15 digits, it is truncated. Left-aligned cells with a leading quote or a green triangle are stored as text and retain the full string.

Explicit limitation: These checks detect precision loss that has already occurred. They cannot recover original digits. If any check fails, the only remedy is to return to the original data source and re-import the affected columns as text.

File Structure Constraints vs. Application Behavior

The XLS binary format defines what can be stored. Applications define how stored values are displayed. Confusing the two leads to false confidence in data integrity.

  • File structure: [MS-XLS] Section 2.1.5 specifies that numeric cells use either an RK record (32-bit or 64-bit floating-point) or a NUMBER record (64-bit IEEE 754 double). No record type encodes arbitrary precision, exact decimal scaling, or integer-only semantics. The format index stored alongside the value references a format string (e.g., #,##0.00) that controls display only.
  • Application rendering: Excel may display 12345678901234500000 as 1.23457E+19 in a narrow column and as the full integer in a wide column. LibreOffice Calc may apply different default formatting. Google Sheets converts XLS data to its own internal representation on import, which may introduce additional rounding. None of these rendering differences change the stored binary value.
  • Format strings: An XLS file can store a format string like 00000 or Text in the format table. Applying a text format to a cell that already contains a number does not convert the stored value to text. The underlying NUMBER record remains unchanged. The format string affects only how the application renders the cell on screen and in print.

Reference: The [MS-XLS] specification is available at Microsoft Open Specifications. Section 2.5.1 documents the NUMBER record structure. Section 2.5.2 documents the RK record. The format table and format index mechanism are described in Section 2.1.6.