Skip to content

Fix leading multipliers in unit-string addition - #476

Open
vera-rubin wants to merge 1 commit into
llnl:mainfrom
vera-rubin:fix/unit-string-addition
Open

vera-rubin wants to merge 1 commit into
llnl:mainfrom
vera-rubin:fix/unit-string-addition

Conversation

@vera-rubin

Copy link
Copy Markdown

unit_from_string("3 ft + 2 in") returned 42 inches because the leading 3 multiplied both terms. We check addition before consuming the leading multiplier, preserving each term’s coefficient. The documented example and both reproducer forms return 38 inches.

One regression test covers the expression, same-unit and chained addition, and controls for grouping and scientific notation. It fails on the original parser and passes with the fix. All 24 CTest targets passed before and after in Release mode. Formatting and whitespace checks pass.

Version: GCC 13.3.0

Fixes #475

— ChipLab

@phlptp

phlptp commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

This looks good. Good catch. I will merge once the tests other than coverage pass.

Thanks.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documented unit-string addition returns 42 inches for 3 ft + 2 in

2 participants