Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

MathHelper.Clamp Method

Restricts a value to be within a specified range.

Namespace: Microsoft.Xna.Framework
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public static float Clamp (
         float value,
         float min,
         float max
)

Parameters

value
The value to clamp.
min
The minimum value. If value is less than min, min will be returned.
max
The maximum value. If value is greater than max, max will be returned.

Return Value

The clamped value.
  • If value > max, max will be returned.
  • If value < min, min will be returned.
  • If minvaluemax, value will be returned.

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone 7

Community Additions

ADD
Show:
© 2015 Microsoft