# underscore.number

Number-related functions missing from underscore.js

# Underscore.number

sign _.num.sign(num)

Returns a sign of `num` as `-1`, `0` or `1`.

pinch _.num.pinch(num, min, max)

Puts `num` in a range of `min` to `max`.

Returns `min` if `num` is smaller than `min`, `max` if `num` is larger than `max`, and `num` itself if it’s already in a range of `min` to `max`.

loop _.num.loop(num, min, max)

Converts `num` as it is in a circular range of `min` to `max` (excluding `max`).

Considering the expression, `_.num.loop(480, 0, 360)` as an angle calculation, it converts 480 degrees in a range of 0 to 360 degrees.

clockwise _.num.clockwise(from, to, range)

Returns the clockwise distance from `from` to `to` as they are in a circle of `range`. Useful to calculate angles.

nearer _.num.nearer(from, to, range)

Returns the nearer distance from `from` to `to` as they are in a circle of `range`. Useful to calculate angles.

average _.num.average(*nums)

Returns an average of `nums`

round _.num.round(num, level)

Rounds `num` by specified `level`.

between _.num.between(from, to, ratio)

Adds `nums`.

sub _.num.sub(base, *nums)

Subtracts `nums` from `base`.

mul _.num.mul(*nums)

Multiplies `nums`.

div _.num.div(base, *nums)

Divides `base` by `nums`.

random _.num.random([a[, b]])

Returns a random number.