Conversation
Contributor
paulsaxe
commented
Nov 22, 2025
- Fixed a problem caused by numerical imprecision of For loops with floating points values causing termination too early, and also ugly directory names, etc. like 3.00000000002 or 2.999999999998
* Fixed a problem caused by numerical imprecision of For loops with floating points values causing termination too early, and also ugly directory names, etc. like 3.00000000002 or 2.999999999998
There was a problem hiding this comment.
Pull request overview
This PR addresses floating-point precision issues in For loops that caused early termination and generated malformed directory names (e.g., "3.00000000002" or "2.999999999998"). The fix calculates the number of decimal places from loop parameters and applies rounding to maintain precision throughout loop iterations.
Key Changes
- Added logic to calculate decimal precision (
ndigits) based on thestartandstepparameters - Applied rounding to loop counter values during iteration count calculation and actual loop execution
- Updated HISTORY.rst to document the bugfix
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| loop_step/loop.py | Adds decimal precision calculation and rounding logic to handle floating-point arithmetic in For loops |
| HISTORY.rst | Documents the bugfix in version 2025.9.22 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…precision and also ensuring the iteration directory names are properly formatted.
* This fix addresses floating-point precision issues in For loops that caused early termination and generated malformed directory names (e.g., "3.00000000002" or "2.999999999998"). The fix calculates the number of decimal places from loop parameters and applies rounding to maintain precision throughout loop iterations.
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.