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

Clarify INumber.IsPositive and INumber.IsNegative documentation #80026

Merged
merged 2 commits into from Jan 8, 2023

Conversation

JochCool
Copy link
Contributor

The method name and documentation of INumber<TSelf>.IsPositive(TSelf) implied that it would only return true for positive numbers, therefore excluding zero. However, all implementations of this interface do return true for zero.

I also clarified that these methods only return true for real numbers, as complex numbers cannot be categorised into strictly "positive" and "negative".

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Dec 28, 2022
@ghost
Copy link

ghost commented Dec 28, 2022

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Issue Details

The method name and documentation of INumber<TSelf>.IsPositive(TSelf) implied that it would only return true for positive numbers, therefore excluding zero. However, all implementations of this interface do return true for zero.

I also clarified that these methods only return true for real numbers, as complex numbers cannot be categorised into strictly "positive" and "negative".

Author: JochCool
Assignees: -
Labels:

area-System.Numerics, community-contribution

Milestone: -

@tannergooding
Copy link
Member

You'll also need to update the docs here https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Numerics/INumberBase%601.xml

It's worth noting that in the mathematics world whether or not zero is considered positive is up to some debate and may depend on your field, specialization, or even country of origin. There are sides that view it as neither positive nor negative and sides that view it as both positive and negative. Likewise, due to it being a natural number there are cases where math allows it to be included in the positive domain but where it may still be treated differently from numbers that are viewed as strictly positive.

That all being said, in the computer programming world and particularly due to things like the IEEE 754 standard, the existence of one's complement numbers, error introduced by rounding, and even for performance reasons it is frequently considered that zero is positive (or more specifically 0 and +0 are positive, where-as -0 is negative) .

@dnfadmin
Copy link

dnfadmin commented Dec 28, 2022

CLA assistant check
All CLA requirements met.

@JochCool
Copy link
Contributor Author

Yes, I'll open a pull request for the other repository once the phrasing is finalised here.

And yeah there are other definitions of "positive", but excluding zero is by far the most widespread, at least in Western education. And in any case, when multiple different definitions are present, it is always worth clarifying which definition is being used.

Copy link
Contributor

@dakersnar dakersnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think this wording update is clearer. LGTM.

@stephentoub stephentoub merged commit 0c85bb9 into dotnet:main Jan 8, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Numerics community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants