C# Class Aura.Shared.Util.Math2

A few commonly used math-related functions.
Mostra file Open project: aura-project/aura

Public Methods

Method Description
Between ( int val, int min, int max ) : bool

Returns true if val is between min and max (incl).

Clamp ( float min, float max, float val ) : float

Returns min, if val is lower than min, max, if val is greater than max, or simply val.

Clamp ( int min, int max, int val ) : int

Returns min, if val is lower than min, max, if val is greater than max, or simply val.

Clamp ( long min, long max, long val ) : long

Returns min, if val is lower than min, max, if val is greater than max, or simply val.

MultiplyChecked ( int initialValue, double multiplicator ) : int

Multiplies initial value with multiplicator, returns either the result or Min/MaxValue if the multiplication caused an overflow.

MultiplyChecked ( long initialValue, double multiplicator ) : long

Multiplies initial value with multiplicator, returns either the result or Min/MaxValue if the multiplication caused an overflow.

MultiplyChecked ( short initialValue, double multiplicator ) : short

Multiplies initial value with multiplicator, returns either the result or Min/MaxValue if the multiplication caused an overflow.

Method Details

Between() public static method

Returns true if val is between min and max (incl).
public static Between ( int val, int min, int max ) : bool
val int
min int
max int
return bool

Clamp() public static method

Returns min, if val is lower than min, max, if val is greater than max, or simply val.
public static Clamp ( float min, float max, float val ) : float
min float
max float
val float
return float

Clamp() public static method

Returns min, if val is lower than min, max, if val is greater than max, or simply val.
public static Clamp ( int min, int max, int val ) : int
min int
max int
val int
return int

Clamp() public static method

Returns min, if val is lower than min, max, if val is greater than max, or simply val.
public static Clamp ( long min, long max, long val ) : long
min long
max long
val long
return long

MultiplyChecked() public static method

Multiplies initial value with multiplicator, returns either the result or Min/MaxValue if the multiplication caused an overflow.
public static MultiplyChecked ( int initialValue, double multiplicator ) : int
initialValue int
multiplicator double
return int

MultiplyChecked() public static method

Multiplies initial value with multiplicator, returns either the result or Min/MaxValue if the multiplication caused an overflow.
public static MultiplyChecked ( long initialValue, double multiplicator ) : long
initialValue long
multiplicator double
return long

MultiplyChecked() public static method

Multiplies initial value with multiplicator, returns either the result or Min/MaxValue if the multiplication caused an overflow.
public static MultiplyChecked ( short initialValue, double multiplicator ) : short
initialValue short
multiplicator double
return short