You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by "anishmehta24 (via GitHub)" <gi...@apache.org> on 2026/09/20 11:49:31 UTC

[PR] GH-4239: xsd:boolean() of a NaN double is false [jena]

anishmehta24 opened a new pull request, #4244:
URL: https://github.com/apache/jena/pull/4244

   GitHub issue resolved #4239
   
   Pull request Description:
   
   `CastXSD.castToBoolean` tested for NaN with `NodeValue.sameValueAs(nv, nvDoubleNaN)`. That is never true, since NaN is not the same value as anything (including itself, which `NVCompare.sameExceptNaN` enforces on the same-term fast path), so `xsd:boolean("NaN"^^xsd:double)` fell through to `true`. The float case only worked by accident: `"NaN"^^xsd:float` is a different term from `nvDoubleNaN`, so it skipped the fast path and hit `Double.compare(NaN, NaN) == 0` in `compareNumeric`.
   
   The numeric branch now returns `XSDFuncOp.effectiveBooleanValue(nv)`, which already implements exactly the XPath casting rule the comment above the method quotes (zero, -0.0 and NaN are false, every other number true), so the three `sameValueAs` probes and their static imports go away.
   
   Tests: `TestCastXSD.cast_to_boolean_06a` (double NaN, fails on `main`), plus `06b`/`06c` for ±INF. `TestCastXSD`, `TestExpressions2` and `TestNodeValue` pass.
   
   ----
   
    - [x] Tests are included.
    - [ ] Documentation change and updates are provided for the [Apache Jena website](https://github.com/apache/jena-site/) (not needed)
    - [x] Commits have been squashed to remove intermediate development commit messages.
    - [x] Key commit messages start with the issue number (GH-xxxx)
   
   By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-4239: xsd:boolean() of a NaN double is false [jena]

Posted by "anishmehta24 (via GitHub)" <gi...@apache.org>.
anishmehta24 commented on PR #4244:
URL: https://github.com/apache/jena/pull/4244#issuecomment-5750096472

   Right, #4246 needs this commit (the strict NaN `sameValueAs` there exposes the float-NaN cast case), so I have folded both into #4246, one commit per issue, and closed this one to avoid the duplicate.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-4239: xsd:boolean() of a NaN double is false [jena]

Posted by "anishmehta24 (via GitHub)" <gi...@apache.org>.
anishmehta24 closed pull request #4244: GH-4239: xsd:boolean() of a NaN double is false
URL: https://github.com/apache/jena/pull/4244


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org


Re: [PR] GH-4239: xsd:boolean() of a NaN double is false [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on PR #4244:
URL: https://github.com/apache/jena/pull/4244#issuecomment-5749943119

   The changes here are also in #4246.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org