Math.Clamp is missing documentation on its thrown exception for degenerate ranges #10677
Labels
area-System.Runtime
help wanted
Good for community contributors to help [up-for-grabs]
Pri3
Indicates issues/PRs that are low priority
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Type of issue
Code doesn't work
Description
Math.Clamp
is currently documented as returning, in order of precedence:value
- wheremin
<=value
<=max
;min
- wherevalue
<min
; ormax
- wheremax
<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 anArgumentException
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
The text was updated successfully, but these errors were encountered: