The Javascript Math namespace.

- allFlags(flags, mask)
- anyFlags(flags, mask)
- clamp(val, min, max)
- isInteger(val)
- isZero(val)
- randomInt(min, max)
- serp(start, end, val)
- trueRound(val, digits)

Check if all the bits in a given mask have been set in a flag variable.

flags:The set of flags to examine.

mask:The bitmask to check against `flags`

.

true if all the bits set in `mask`

were also set in `flags`

, false otherwise.

Always returns false if `mask == 0`

.

Check if any of the bits in a given mask have been set in a flag variable.

flags:The set of flags to examine.

mask:The bitmask to check against `flags`

.

true if any of the bits set in `mask`

were also set in `flags`

, false otherwise.

Always returns false if `mask == 0`

.

Clamps a value between two bounds.

val:The value to clamp.

min:The minimum value to accept.

max:The maximum value to accept.

`val`

, if `val`

was between `min`

and `max`

. `max`

, if `val`

was greater than `max`

. `min`

, if `val`

was less than `min`

.

Determines if a value is an integer.

val:The value to examine.

true if `val == parseInt(Number(val))`

, false otherwise.

Always returns false if `val`

is `undefined`

, `null`

or `isNaN(val) == true`

.

Quickly check if a value is small enough to consider it as being zero for practical purposes.

val:A value to check for zero-ness.

true if `val`

was within `+/- 1E-06`

of `0.0`

, false otherwise.

Get a randomly-generated integer between two bounds (inclusively).

min:The minimum value to generate.

max:The maximum value to generate.

A random integer between the given bounds, inclusive.

Interpolates between two values using a sine wave.

start:The starting value (when `val == 0.0`

).

end:The final value (when `val == 1.0`

).

val:The value used for interpolation.

A value along a sine wave between the start and end values.

For a neat start-finish interpolation, `val`

should be clamped between `0.0`

and `1.0`

but since sine is cyclical this is not essential.

Precise rounding to a fixed number of digits.

val:The value to round.

digits:The number of digits to round `val`

to.

A string containing `val`

rounded to the specified number of digits.

More information: Stack Overflow: round off decimal using javascript