center()

Returns the given value unless its absolute value is smaller than the specified threshold, in which case it returns 0.

Syntax

center(value, min)

Parameters

Parameter Type Description
value Number The numeric value to check.
min Number The threshold below which the value becomes zero.

Return Value

Examples

center(5, 3);  // returns 5
center(2, 3);  // returns 0
center(-1, 2); // returns 0
center(-4, 2); // returns -4

See also

round
roundup
floor
ceil
trunc
center
centerex