computes floor and ceiling for any modulus, not just 1
node
> require('mod-floor-ceiling').modFloor(3.8, 1.7)
3.4
> require('mod-floor-ceiling').modFloor(3.4, 1.7)
3.4
> require('mod-floor-ceiling').modCeiling(-17.8, 2.5)
-17.5
> require('mod-floor-ceiling').modLower(15, 5)
10
> require('mod-floor-ceiling').modLower(16, 5)
15
> require('mod-floor-ceiling').modHigher(15, 5)
20
> require('mod-floor-ceiling').modHigher(14, 5)
15
npm install mod-floor-ceiling
Returns the greatest (closest to positive infinity) multiple of modulus
, plus anchor
, that is <= value
.
Returns the least (closest to negative infinity) multiple of modulus
, plus anchor
, that is >= value
.
Returns the greatest (closest to positive infinity) multiple of modulus
, plus anchor
, that is < value
.
Returns the greatest (closest to positive infinity) multiple of modulus
, plus anchor
, that is > value
.
Anchor controls the offset of multiples of modulus.
For example, with a modulus of 3 and the default anchor of 0, possible return values include -6, -3, 0, 3, 6, etc.
But with anchor of 1, possible return values include -5, -2, 1, 4, 7, etc.
It's simple; modFloor(value, modulus, anchor)
just computes anchor + modFloor(value - anchor, modulus)
.