dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

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

Open rjgotten opened this issue 1 year ago • 2 comments

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

rjgotten avatar Nov 13 '24 12:11 rjgotten

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

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

tannergooding avatar Nov 19 '24 22:11 tannergooding