Open
Description
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 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