Skip to content

Clarify that the multiply() sign rules don't apply if the result is NaN #92

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

Closed
wants to merge 1 commit into from

Conversation

asmeurer
Copy link
Member

We should actually define "mathematical sign" somewhere (especially since it
really means "sign bit"), but I'm not sure where this definition should go.

We should actually define "mathematical sign" somewhere (especially since it
*really* means "sign bit"), but I'm not sure where this definition should go.
@kgryte
Copy link
Contributor

kgryte commented Nov 21, 2020

Re: mathematical sign. No, the intent is not the sign bit; that is an implementation detail. We mean by mathematical sign the sign attribute of a number. One way to check the sign of a floating-point number is by examining the binary representation of an IEEE 754 float, but this is not the only way. Comparison with zero and, for signed zero, division of one will also inform us as to the sign attribute.

Re: this PR. I am not in favor of including these changes as the phrasing is not correct. This PR indicates that a NaN result is the exception, or must obey alternative rules, but this is not required. As discussed elsewhere, an implementation could choose to returned a "signed" NaN for purposes of encoding the signed-ness of the operands.

The current spec is not contradictory in this regard, as both rules can be true at the same time. If there is ambiguity regarding how a NaN should be encoded, that is purposeful, as the signed-ness of NaN is implementation defined. While I am not in favor of the current changes, I am open to including a note or some such explanatory phrase indicating that how NaN values are encoded is implementation defined.

@asmeurer
Copy link
Member Author

Well to me "mathematical sign" means the mathematical definition of sign, which is akin to what the sign() function returns (mathematically 0 and -0 are the same thing, and 0 is neither positive nor negative). So while perhaps "sign bit" suggests an implementation detail, "mathematical sign" isn't much better than what was here before. I would suggest finding a better term, and more importantly, actually defining it.

Re: this PR. I am not in favor of including these changes as the phrasing is not correct.

The current phrasing is also not correct if nan is allowed to not have a "mathematical sign", as it says that the result does have a sign (which is positive/negative). So if nan is allowed to not have a sign, it must be excluded from the rules that talk about mathematical sign. This doesn't preclude nan having a sign if the implementation choses that (although this is currently impossible to test in-spec as we don't have any functions that return the sign of a number).

@kgryte
Copy link
Contributor

kgryte commented Nov 23, 2020

I've opened a PR for RFC 2119 compliance which also includes language which should address the concerns in this PR.

It is not that the rules for mathematical sign don't (or more precisely can't) apply to a NaN result, it is that we shouldn't require specification conforming implementations to follow any particular convention. In short, whether a NaN result is signed or not should be implementation-defined.

asmeurer added a commit to data-apis/array-api-tests that referenced this pull request Dec 2, 2020
@rgommers
Copy link
Member

I agree that NaN shouldn't be special-cased here, and I think gh-94 addressed the concern here. So I'll close this PR. Thanks @asmeurer and @kgryte

@rgommers rgommers closed this Jan 26, 2021
@honno honno deleted the multiply-sign-rule branch February 28, 2024 13:20
cr313 added a commit to cr313/test-array-api that referenced this pull request Apr 19, 2024
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.

3 participants