kisame1313

Clamp

Jul 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.28 KB | None | 0 0
  1. public static int Clamp ( int value, int minValue, int maxValue )
  2.         {
  3.             int result;
  4.             if ( value <= minValue )
  5.             {
  6.                 if ( value >= maxValue )
  7.                 {
  8.                     return value;
  9.                 }
  10.                 else
  11.                 {
  12.                     return maxValue;
  13.                 }
  14.             }
  15.             else
  16.             {
  17.                 return minValue;
  18.             }
  19.         }
Advertisement
Add Comment
Please, Sign In to add comment