Skip to content

Conversation

TomA-R
Copy link
Contributor

@TomA-R TomA-R commented Oct 19, 2025

Updates the IS_DOUBLE branch to use Z_DVAL_P(from) instead of Z_LVAL_P(from). The old code was reading from the integer slot, which isn’t defined for doubles and could return garbage.

The new logic follows PHP's own casting rules: 0.0 and -0.0 are false, everything else (1.5, INF, -INF, NAN) is true.

Added a PHPT test that fails with the old code but passes with this change.

No API changes, just correctness and consistency with PHP itself.

We were reading floats like integers when converting to bool, which made -0.0 incorrectly evaluate to true. Using the proper float accessor fixes this and matches PHP: 0.0 and -0.0 are false; any non-zero float is true.
@TomA-R TomA-R requested a review from a team as a code owner October 19, 2025 00:37
@TomA-R TomA-R requested review from haberman and removed request for a team October 19, 2025 00:37
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.

1 participant