In This Article

MathHelper Class

Provides math routines not found in Math class as well as additional helper methods.

public static class MathHelper
Inheritance:
object object

Methods

Max(params double[])

Returns the largest value from the specified numbers.

public static double Max(params double[] values)
Parameter Type Description
values double[]

The values to compare.

Returns

double:

The largest value from the specified numbers.

Max(params int[])

Returns the largest value from the specified numbers.

public static int Max(params int[] values)
Parameter Type Description
values int[]

The values to compare.

Returns

int:

The largest value from the specified numbers.

Min(params double[])

Returns the smallest value from the specified numbers.

public static double Min(params double[] values)
Parameter Type Description
values double[]

The values to compare.

Returns

double:

The smallest value from the specified numbers.

Min(params int[])

Returns the smallest value from the specified numbers.

public static int Min(params int[] values)
Parameter Type Description
values int[]

The values to compare.

Returns

int:

The smallest value from the specified numbers.

Range(decimal, decimal, decimal)

Returns the specified value constrained to the specified minimum and maximum values.

public static decimal Range(decimal value, decimal minValue, decimal maxValue)
Parameter Type Description
value decimal

The value.

minValue decimal

The minimum value.

maxValue decimal

The maximum value.

Returns

decimal:

The specified value constrained to the specified minimum and maximum values.

Range(double, double, double)

Returns the specified value constrained to the specified minimum and maximum values.

public static double Range(double value, double minValue, double maxValue)
Parameter Type Description
value double

The value.

minValue double

The minimum value.

maxValue double

The maximum value.

Returns

double:

The specified value constrained to the specified minimum and maximum values.

Range(int, int, int)

Returns the specified value constrained to the specified minimum and maximum values.

public static int Range(int value, int minValue, int maxValue)
Parameter Type Description
value int

The value.

minValue int

The minimum value.

maxValue int

The maximum value.

Returns

int:

The specified value constrained to the specified minimum and maximum values.

Round(RoundMode, double)

Returns a rounded number using the specified RoundMode.

public static double Round(RoundMode mode, double value)
Parameter Type Description
mode RoundMode

The RoundMode to use.

value double

The value to round.

Returns

double:

A rounded number using the specified RoundMode.

Inherited Members