Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating Point and Php Nightly 8.4 #3897

Merged
merged 1 commit into from
Feb 7, 2024
Merged

Conversation

oleibman
Copy link
Collaborator

@oleibman oleibman commented Feb 6, 2024

Fix #3896. It appears that floating-point arithmetic will give different results in Php 8.4 vs. all earlier releases. This causes tests to fail in the nightly run for ROUNDDOWN, ROUNDUP, and AMORDEGRC. I imagine this won't be the last we hear of this. The failures are a distraction when reviewing PR's. This PR eliminates the distraction by adding in a fudge factor for Php 8.4+ while not changing Php 8.3-. It is not a particularly robust solution, but it should be stable for Php 8.3-, and good enough for Php 8.4+ while I study if a better solution is available.

This is:

  • a bugfix
  • a new feature
  • refactoring
  • additional unit tests

Checklist:

  • Changes are covered by unit tests
    • Changes are covered by existing unit tests
    • New unit tests have been added
  • Code style is respected
  • Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • Documentation is updated as necessary

Why this change is needed?

Provide an explanation of why this change is needed, with links to any Issues (if appropriate).
If this is a bugfix or a new feature, and there are no existing Issues, then please also create an issue that will make it easier to track progress with this PR.

Fix PHPOffice#3896. It appears that floating-point arithmetic will give different results in Php 8.4 vs. all earlier releases. This causes tests to fail in the nightly run for ROUNDDOWN, ROUNDUP, and AMORDEGRC. I imagine this won't be the last we hear of this. The failures are a distraction when reviewing PR's. This PR eliminates the distraction by adding in a fudge factor for Php 8.4+ while not changing Php 8.3-. It is not a particularly robust solution, but it should be stable for Php 8.3-, and good enough for Php 8.4+ while I study if a better solution is available.
@oleibman oleibman added this pull request to the merge queue Feb 7, 2024
Merged via the queue into PHPOffice:master with commit 3512304 Feb 7, 2024
14 checks passed
@oleibman oleibman deleted the round84 branch February 7, 2024 17:38
oleibman added a commit to oleibman/PhpSpreadsheet that referenced this pull request Sep 7, 2024
Changes to Php8.4 floating point calculations caused failures in unit tests for ROUNDDOWN, ROUNDUP, and AMORDEGRC. These were addressed in a kludgey manner by PR PHPOffice#3897. Then someone reported a problem (not specifically related to Php8.4) with TRUNC. That was fixed by PR PHPOffice#4115, in which I applied the method used by TRUNC to ROUNDDOWN and ROUNDUP as well. The method used to fix these was to cast a floating point value to string and then cast it back to float again. It's a bit surprising that this works, but it seems effective for all our test cases, and is less kludgey than what had been done earlier. Missing from that PR was a similar change for AMORDEGRC. This PR applies that change to AMORDEGRC, which again passes the unit test suite for all releases of Php.
@oleibman oleibman mentioned this pull request Sep 7, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

First Php8.4 Problem - ROUNDUP and ROUNDDOWN
1 participant