Skip to content

Drop the Debug.Assert that rejects decimals like 10.0m - #115

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/rendered-float-trailing-zero-assert
Sep 27, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/rendered-float-trailing-zero-assert

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #112

Summary

ParseRenderedFloat trims trailing zeros from the rendered text. A decimal with more than one integer digit and only zeros after the point (10.0m, 100.00m, -20.0m) comes out of that as "10.", with an empty fraction. The Debug.Assert after the loop required an empty fraction to come with a single integer digit. The loop does not guarantee that, so Debug builds ended the process with Unexpected format: 10. on valid input. Release builds compiled the assert out and returned the correct value.

The code after the assert already handles an empty fraction: it contributes no digits and no exponent shift. So the fix is to remove the assert.

Tests

FromDecimalWithOnlyZerosAfterThePoint converts 10.0m, 100.00m, -20.0m and -1200.000m, both through ToPreciseNumber() and in every generic conversion mode. It runs in the default Debug test configuration.

  • With the assert restored, the test host aborts with Assertion Failed / Unexpected format: 10..
  • With it removed, the full suite passes (386 tests), and the library builds for every target framework with no warnings.

This branch is independent of #113 and #114. Each PR is based on main alone.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QK96a24CjVhUK9u1Ss2YNN


Generated by Claude Code

ParseRenderedFloat trims trailing zeros from the rendered text, so a decimal
with more than one integer digit and only zeros after the point, such as
10.0m, 100.00m or -20.0m, becomes "10." with an empty fraction. The assert
after the loop required an empty fraction to come with a single integer
digit, which the loop does not guarantee, so Debug builds ended the process
with "Unexpected format: 10." on valid input. Release builds compiled the
assert out and returned the right value. The code after the assert already
handles an empty fraction, so the assert goes.

Fixes #112

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QK96a24CjVhUK9u1Ss2YNN
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 92b1d20 into main Sep 27, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the claude/rendered-float-trailing-zero-assert branch September 27, 2026 00:19
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.

Debug builds crash converting decimals like 10.0m or 100.00m: Debug.Assert in ParseRenderedFloat fires on valid input

2 participants