MATH::ROUND 1g 2023-11-22 laplante@plcb.ca GOWEB/MATH


title: “MATH::ROUND Function” author: “Pierre Laplante laplante@plcb.ca” date: “2023-11-22” version: “1.0.0” section: “1g”

category: “GOWEB/MATH”

Name

math::round returns the nearest integer value to x.

Synopsis

math::round or round(expression[, decimal: integer])

Description

The math::round function returns the nearest integer value to x.
By default, rounding is performed half away from zero (i.e., 0.5 rounds to 1, -0.5 rounds to -1).

When the optional decimal parameter is provided (from 0 to 10), the result is rounded to the specified number of decimal places.

Parameters

Examples

res={{
    round(2.5);        // 3
    round(-2.5);       // -3
    round(3.14159, decimal:2); // 3.14
    round(-3.14159, decimal:2); // -3.14
    round([1.1, 2.5, 3.7]);     // [1, 3, 4]
    round({"x": 2.718, "y": 3.14159}, decimal:3); // {"x":2.718,"y":3.142}
}}.

return

res=3-33.14-3.14[1,3,4]{"x":2.718,"y":3.142}.

Author

Pierre Laplante laplante@plcb.ca

See also

Version