Skip to content

interp: fix GE/LE operators to handle double-precision comparison#2525

Merged
rene-dev merged 1 commit intoLinuxCNC:2.9from
snowgoer540:gregc/floating-point
Jun 18, 2023
Merged

interp: fix GE/LE operators to handle double-precision comparison#2525
rene-dev merged 1 commit intoLinuxCNC:2.9from
snowgoer540:gregc/floating-point

Conversation

@snowgoer540
Copy link
Copy Markdown
Contributor

This commit does four things:

  1. Changes the LE/GE operators to better handle double-precision floating-point comparisons. When comparing two values as equal (or not equal) the EQ and NE operators considered the floating-point precision "issue" by comparing the difference between the two values to TOLERANCE_EQUAL, GE and LE did not.
  2. Simplify the difference code by using fabs()
  3. Modify the TOLERANCE_EQUAL threshold to 1e-6. Previously this was set to .0001 which is very close to a reasonable difference between two gcode coordinate values.
  4. Update the documentation to reflect these change.

This commit does four things:
1. Changes the LE/GE operators to better handle double-precision 
floating-point comparisons. When comparing two values as equal (or not 
equal) the EQ and NE operators considered the floating-point precision 
"issue" by comparing the difference between the two values to 
TOLERANCE_EQUAL, GE and LE did not.
2. Tidy the difference by using fabs()
3. Modify the TOLERANCE_EQUAL threshold to 1e-6.  Previously this was 
set to .0001 which is very close to a reasonable difference between two 
gcode coordinate values.
4. Update the documentation to reflect these change.
@snowgoer540 snowgoer540 changed the base branch from master to 2.9 June 17, 2023 15:54
@snowgoer540 snowgoer540 changed the title interp: fix GE/LE operators to better handle double-precision comparison interp: fix GE/LE operators to handle double-precision comparison Jun 17, 2023
@rene-dev
Copy link
Copy Markdown
Member

the linuxcnc norway meeting approves this PR.

@rene-dev rene-dev merged commit 9f6a8b1 into LinuxCNC:2.9 Jun 18, 2023
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.

2 participants