Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 868 Bytes

File metadata and controls

26 lines (22 loc) · 868 Bytes

Math::Round

Math::Round(x, precision): number

Round floating point value to the nearest integer value or floating point value with given precision.

Table 1. Parameters

x

number

Input value.

precision

int

Optional number of decimal places to be left. If omitted or set to 0, x will be rounded to integer value.

Return

The integral value that is closest to x if precision is omitted or set to 0, or floating point value rounded to have given number of decimal places.

println(Math::Round(2.3)); // Will print "2"
println(Math::Round(3.8)); // Will print "4"
println(Math::Round(-2.3)); // Will print "-2"
println(Math::Round(-3.8)); // Will print "-4"
println(Math::Round(2.378, 2)); // Will print "2.38"
println(Math::Round(2.378, 1)); // Will print "2.4"