{{ message }}
Repository navigation
A number in a spreadsheet is read with the 15 significant digits Excel keeps, not the binary tail of a computed value - #1032
Merged
WaylandYang merged 3 commits intoOct 1, 2026
Conversation
…l keeps, not the binary tail of a computed value Signed-off-by: dada-yan <BinjunYann@gmail.com>
WaylandYang
approved these changes
Oct 1, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Approving. Thanks @Maya-Kid. Reviewed at 0bc7515: rounding to 15 significant digits and printing the shortest form removes the binary tail of a cached formula value and leaves clean values, integers and non-finite values as they were. #1039 moves the cell text into a helper of its own; this lands first and that one picks the arm up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Excel compares and shows numbers to 15 significant digits, but it writes the cached value of a formula to the file at full double precision.
=0.1+0.2is stored as0.30000000000000004and=1.1*1.1-1as0.21000000000000019, while Excel shows 0.3 and 0.21.parsers::spreadsheetprints the double in Rust's shortest round-trip form. That form keeps the tail whenever the computed double is not the one nearest the decimal.Problem
A sheet with cached values the way Excel writes them, read on dev 2e7ba78:
1395.0527999999999reads 1395.0528, and19.899999999999999reads 19.9. Only computed values keep a tail.Change
parsers::spreadsheetwrites aData::Floatcell withexcel_number: the value is rounded to 15 significant digits, then printed in its shortest decimal form.The new arm sits next to
excel_date(#1017).Verification
Run on macOS (arm64): Rust 1.98.1; the workspace suite against PostgreSQL 16 with pgvector 0.8.2, with Poppler 26.06.
crates/utopia-ingest/tests/spreadsheet_numbers.rsbuilds an.xlsxwith values written the way Excel caches them, under the General format:a_computed_number_reads_with_the_digits_excel_keeps: 0.3, 0.21 and -0.3. On dev with only this file added it fails with0.30000000000000004,0.2100000000000002and-0.30000000000000004.a_number_that_was_already_clean_reads_as_before: 1395.0528, 19.9, 1200, 123456789012345000 and 0.125. It passes on dev and here.Other checks:
cargo test --locked -p utopia-ingest: 125 passed.cargo fmt --all --checkandcargo clippy --locked --workspace --all-targets -- -D warningsare clean.UTOPIA_TEST_REQUIRE_DB=1 UTOPIA_TEST_REQUIRE_PDFTOTEXT=1 cargo test --locked --workspace: 1,345 passed, 0 failed, 6 ignored. That run had this change merged with the Word non-breaking-hyphen fix opened alongside it.Not in this change
A cell formatted as a percentage still reads as its fraction (0.125, not 12.5%). calamine gives no number format for cells that are not dates.