Skip to content
Reference > Methods

roundNearestDown(value,bucketSize)

Definition

Number roundNearestDown(Number value, Number bucketSize)

Description

Given the value and the bucket size, returns a Long that rounds DOWN to the closest multiple of the bucket size.

Parameter Definition

Name Type Description
value Number Number to round
bucketSize Number multiple, aka, bucket size to round to

Examples

Integer r1 = roundNearestDown(0,10); // r1 == 0
Integer r2 = roundNearestDown(3,10); // r2 == 0
Integer r3 = roundNearestDown(7,10); // r3 == 0
Integer r4 = roundNearestDown(14,10); // r4 == 10
Integer r5 = roundNearestDown(19,10); // r5 == 10
Integer r6 = roundNearestDown(20,10); // r6 == 20
Integer r7 = roundNearestDown(21,10); // r7 == 20
Integer r8 = roundNearestDown(239,60); // r8 == 180
Integer r9 = roundNearestDown(240,60); // r9 == 240
Integer r10 = roundNearestDown(241,60); // r10 == 240