Preserve fractional values when expanding written magnitudes - #825
Merged
WaylandYang merged 2 commits intoSep 20, 2026
Merged
Conversation
Signed-off-by: dada-yan <BinjunYann@gmail.com>
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.
Problem
1.00000025 millionand100.000025万were parsed as1000000instead of1000000.25. After scaling an f64, the parser rounded values near an integer using a relative tolerance. At this magnitude the tolerance swallowed the genuine.25.This also reaches persisted data: the authenticated attribute-adoption endpoint writes the rounded value when adopting a supported unbound typed value fact. Open-statement alignment is a separate path and is not claimed to be affected by that adoption test.
Change
Represent the existing magnitude words as decimal exponents and parse the validated decimal coefficient with that scale. This converts the scaled decimal directly to f64 instead of multiplying an already rounded float and guessing which remainder is noise.
9.2亿still yields920000000.The exponent spelling is internal; the accepted input grammar, strict/leading parsing policies, currency/unit handling, finite-value check, and f64 return type remain unchanged. No dependency or database change. The temporary numeric string adds at most three bytes to the coefficient, so memory remains linear in the input length.
Validation
Linux with dedicated PostgreSQL/pgvector and
UTOPIA_TEST_REQUIRE_DB=1:1000000.0. The same tests pass after the fix..25, original value history, supersedes, source evidence, unit and audit records for both spellings.-D warnings), workspace tests and build pass: 941 passed, 0 failed, 1 ignored live-public-HTTPS test.This corrects future conversions. It neither rewrites historical rounded values nor automatically undoes already adopted values on rollback. Full decimal precision and broad numeric normalization are outside this change.
Combined regression verification
All five independent fixes merge cleanly onto the same dev baseline. On the combined Linux branch, format, workspace Clippy, build and the full test suite pass (952 passed, 0 failed, 1 explicitly ignored live-public-HTTPS test). A shared authenticated RDF fixture verifies unbound values, subsecond history and explicit ontology links together in Turtle and JSON-LD. Removing each fix individually makes its regression fail again; restoring all fixes returns the full suite to 952 passing tests. No database migration or historical rewrite is included.