Ring1_Intrinsic_clamp
Clamp a value to a range.
Ring1_Result
Ring1_Intrinsic_clamp_suffix
(
type* result,
type x,
type minimum,
type maximum
)
The following table denotes the valid combinations of suffix and type
suffix |
type |
f32 |
float |
f64 |
double |
This function clamps a value to the range 0 (inclusive) and 1 (inclusive):
- a value smaller than
minimum
is mapped tominimum
. - a value greater than
maximum
is mapped tomaximum
. - negative infinity is mapped to
minimum
. - positive infinity is mapped to
maximum
.
Parameter Values
result
- A pointer to a
type variable.
x
- The value to clamp.
minimum
- The minimum of the range.
maximum
- The maximum of the range.
Return Values
Ring1_Result_Success
on success,
Ring1_Result_Failure
on failure.
Post Conditions
If this function fails, then it sets the by-thread status variable.
Below is a list of failure conditions and the status codes indicating them.
Ring1_Status_InvalidArgument
result
wasNULL
.Ring1_Status_InvalidArgument
-
x
,minimum
, and/ormaximum
is not a number. Ring1_Status_InvalidArgument
minimum
is greater thanmaximum
.
If this function succeeds, then *result
was assigned the clamped value.