Math.Clamp Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| Clamp(Double, Double, Double) |
Constrains a value to the specified inclusive range, returning |
| Clamp(Int64, Int32, Int32) |
Constrains a value to the specified inclusive range. |
| Clamp(Int64, Int64, Int64) |
Constrains a value to the specified inclusive range. |
| Clamp(Single, Single, Single) |
Constrains a value to the specified inclusive range, returning |
Clamp(Double, Double, Double)
Constrains a value to the specified inclusive range, returning NaN when value is NaN.
[Android.Runtime.Register("clamp", "(DDD)D", "", ApiSince=35)]
public static double Clamp(double value, double min, double max);
[<Android.Runtime.Register("clamp", "(DDD)D", "", ApiSince=35)>]
static member Clamp : double * double * double -> double
Parameters
- value
- Double
The value to constrain.
- min
- Double
The inclusive lower bound.
- max
- Double
The inclusive upper bound.
Returns
The value constrained to the inclusive range from min to max, or NaN if value is NaN.
- Attributes
Exceptions
if either bound is NaN, min is greater than max, or min is +0.0 and max is -0.0.
Remarks
Throws if either bound is NaN, min is greater than max, or min is +0.0 and max is -0.0.
Applies to
Clamp(Int64, Int32, Int32)
Constrains a value to the specified inclusive range.
[Android.Runtime.Register("clamp", "(JII)I", "", ApiSince=35)]
public static int Clamp(long value, int min, int max);
[<Android.Runtime.Register("clamp", "(JII)I", "", ApiSince=35)>]
static member Clamp : int64 * int * int -> int
Parameters
- value
- Int64
The value to constrain.
- min
- Int32
The inclusive lower bound.
- max
- Int32
The inclusive upper bound.
Returns
The value constrained to the inclusive range from min to max.
- Attributes
Exceptions
if min is greater than max.
Remarks
Throws if min is greater than max.
Applies to
Clamp(Int64, Int64, Int64)
Constrains a value to the specified inclusive range.
[Android.Runtime.Register("clamp", "(JJJ)J", "", ApiSince=35)]
public static long Clamp(long value, long min, long max);
[<Android.Runtime.Register("clamp", "(JJJ)J", "", ApiSince=35)>]
static member Clamp : int64 * int64 * int64 -> int64
Parameters
- value
- Int64
The value to constrain.
- min
- Int64
The inclusive lower bound.
- max
- Int64
The inclusive upper bound.
Returns
The value constrained to the inclusive range from min to max.
- Attributes
Exceptions
if min is greater than max.
Remarks
Throws if min is greater than max.
Applies to
Clamp(Single, Single, Single)
Constrains a value to the specified inclusive range, returning NaN when value is NaN.
[Android.Runtime.Register("clamp", "(FFF)F", "", ApiSince=35)]
public static float Clamp(float value, float min, float max);
[<Android.Runtime.Register("clamp", "(FFF)F", "", ApiSince=35)>]
static member Clamp : single * single * single -> single
Parameters
- value
- Single
The value to constrain.
- min
- Single
The inclusive lower bound.
- max
- Single
The inclusive upper bound.
Returns
The value constrained to the inclusive range from min to max, or NaN if value is NaN.
- Attributes
Exceptions
if either bound is NaN, min is greater than max, or min is +0.0 and max is -0.0.
Remarks
Throws if either bound is NaN, min is greater than max, or min is +0.0 and max is -0.0.