## edu.neu.ccs.util Class MathUtilities

```java.lang.Object
|
+--edu.neu.ccs.util.MathUtilities
```

public class MathUtilities
extends Object

The class `MathUtilities` collects several useful static mathematical functions. The class may be viewed as an extension of the tools found in `java.lang.Math`.

Since:
1.2

 Constructor Summary `MathUtilities()`

 Method Summary `static double` `acosdeg(double value)`           Return the arc cosine in degrees of the specified input value in the range -1 to +1. `static double` `asindeg(double value)`           Return the arc sine in degrees of the specified input value in the range -1 to +1. `static double` ```atan2deg(double y, double x)```           Return the polar angle in degrees of the point (x, y) where the y-coordinate is given first and the x-coordinate second. `static double` `atandeg(double value)`           Return the arc tangent in degrees of the specified input value. `static double` `cosdeg(double degrees)`           Return the cosine of the given angle specified in degrees. `static int` ```GCD(int a, int b)```           Returns the greatest common divisor of the int inputs a and b. `static long` ```GCD(long a, long b)```           Returns the greatest common divisor of the long inputs a and b. `static int` ```LCM(int a, int b)```           Returns the least common multiple of the int inputs a and b. `static long` ```LCM(long a, long b)```           Returns the least common multiple of the long inputs a and b. `static int` ```modulus(int number, int base)```           Returns the modulus of int number relative to int base. `static long` ```modulus(long number, long base)```           Returns the modulus of long number relative to long base. `static double` ```randomDouble(double min, double max)```           Return a random double r in the range min <= r <= max. `static int` ```randomInt(int min, int max)```           Return a random int r in the range min <= r <= max. `static double` `sindeg(double degrees)`           Return the sine of the given angle specified in degrees. `static double` `tandeg(double degrees)`           Return the tangent of the given angle specified in degrees.

 Methods inherited from class java.lang.Object `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

 Constructor Detail

### MathUtilities

`public MathUtilities()`
 Method Detail

### randomInt

```public static int randomInt(int min,
int max)```
Return a random int r in the range min <= r <= max.

### randomDouble

```public static double randomDouble(double min,
double max)```
Return a random double r in the range min <= r <= max.

### sindeg

`public static double sindeg(double degrees)`
Return the sine of the given angle specified in degrees.

### cosdeg

`public static double cosdeg(double degrees)`
Return the cosine of the given angle specified in degrees.

### tandeg

`public static double tandeg(double degrees)`
Return the tangent of the given angle specified in degrees.

### asindeg

`public static double asindeg(double value)`
Return the arc sine in degrees of the specified input value in the range -1 to +1.

### acosdeg

`public static double acosdeg(double value)`
Return the arc cosine in degrees of the specified input value in the range -1 to +1.

### atandeg

`public static double atandeg(double value)`
Return the arc tangent in degrees of the specified input value.

### atan2deg

```public static double atan2deg(double y,
double x)```
Return the polar angle in degrees of the point (x, y) where the y-coordinate is given first and the x-coordinate second.

Parameters:
`y` - the y-coordinate of the point
`x` - the x-coordinate of the point

### GCD

```public static int GCD(int a,
int b)```

Returns the greatest common divisor of the int inputs a and b.

The return value will be positive or zero and will be zero only if both a and b are zero.

### GCD

```public static long GCD(long a,
long b)```

Returns the greatest common divisor of the long inputs a and b.

The return value will be positive or zero and will be zero only if both a and b are zero.

### LCM

```public static int LCM(int a,
int b)```

Returns the least common multiple of the int inputs a and b.

The return value will be positive or zero and will be zero only if both a and b are zero.

### LCM

```public static long LCM(long a,
long b)```

Returns the least common multiple of the long inputs a and b.

The return value will be positive or zero and will be zero only if both a and b are zero.

### modulus

```public static int modulus(int number,
int base)```

Returns the modulus of int number relative to int base.

Returns n such that n is congruent to number modulo base and 0 <= n < Math.abs(base).

Throws `ArithmeticException` if base is zero.

### modulus

```public static long modulus(long number,
long base)```

Returns the modulus of long number relative to long base.

Returns n such that n is congruent to number modulo base and 0 <= n < Math.abs(base).

Throws `ArithmeticException` if base is zero.