Skip to content

Bugfix: fixed numerical precision in For loops#36

Merged
seamm merged 3 commits intomainfrom
dev
Nov 22, 2025
Merged

Bugfix: fixed numerical precision in For loops#36
seamm merged 3 commits intomainfrom
dev

Conversation

@paulsaxe
Copy link
Contributor

  • 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
Copy link
Contributor

@seamm seamm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the start and step parameters
  • 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.
@seamm seamm merged commit acb69d6 into main Nov 22, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants