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

Math.Clamp is missing documentation on its thrown exception for degenerate ranges #10677

Open
rjgotten opened this issue Nov 13, 2024 · 2 comments
Labels
area-System.Runtime help wanted Good for community contributors to help [up-for-grabs] Pri3 Indicates issues/PRs that are low priority

Comments

@rjgotten
Copy link

rjgotten commented Nov 13, 2024

Type of issue

Code doesn't work

Description

Math.Clamp is currently documented as returning, in order of precedence:

  1. value - where min <= value <= max;
  2. min - where value < min; or
  3. max - where max < value.

This means it should support degenerate ranges such as Math.Clamp(10, 0, -2) and result in the 2nd case, returning 0.

This is actually not how the method is implemented.
It expressly checks for min <= max and throws an ArgumentException in cases that don't fit this constraint.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.math.clamp?view=net-8.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System/Math.xml

Document Version Independent Id

8e48c3bd-8e68-e4c7-167c-07efd236a06f

Article author

@dotnet-bot

@issues-automation issues-automation bot added the Pri3 Indicates issues/PRs that are low priority label Nov 13, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Nov 13, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime

@tannergooding tannergooding added help wanted Good for community contributors to help [up-for-grabs] and removed untriaged New issue has not been triaged by the area owner labels Nov 19, 2024
@tannergooding
Copy link
Member

Should be a simple thing to fix, marked this as help-wanted for anyone who's interested in picking it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Runtime help wanted Good for community contributors to help [up-for-grabs] Pri3 Indicates issues/PRs that are low priority
Projects
None yet
Development

No branches or pull requests

3 participants
@rjgotten @tannergooding and others