Fix float_to_str for negative values and zero-padding#119
Open
ColtonPayne wants to merge 1 commit intomainfrom
Open
Fix float_to_str for negative values and zero-padding#119ColtonPayne wants to merge 1 commit intomainfrom
ColtonPayne wants to merge 1 commit intomainfrom
Conversation
Use abs() before modulo to prevent Python's modulo returning incorrect positive remainders for negative floats (BUG-102). Add 3-digit zero- padding to preserve leading zeros in the fractional part (BUG-103). Use round() instead of int() to avoid floating-point truncation errors. Applied to interpretation.py, interpretation_fp.py, and interpretation_parallel.py. Added parametrized tests covering negative values, zero-padding, and combined cases across both backends. Also guard .cache_status.yaml write so test runners (pytest/unittest) no longer dirty the repo file during pre-commit hooks. Closes #93 Closes #94 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.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.
Summary
float_to_str()producing incorrect output for negative floats due to Python's modulo behavior (-3.456 % 1 = 0.544). Usesabs()before modulo and handles the-0.xxxsign case.3.001rendered as"3.1"). Now always produces 3 decimal digits.round()instead ofint()for the decimal part to avoid floating-point truncation errors.interpretation.py,interpretation_fp.py, andinterpretation_parallel.py..cache_status.yamlwrite behind a test-runner check so pre-commit hooks no longer dirty the repo file.Test plan
test_float_to_str_negative_values— parametrized over 3 negative float casestest_float_to_str_zero_padding— parametrized over 4 leading-zero casestest_float_to_str_negative_with_zero_padding— parametrized over 2 combined casesinterpretation_fpandinterpretationbackendsCloses #93
Closes #94
🤖 Generated with Claude Code