round

round

> Functions

Returns number rounded to the nearest integer. You can round down to the integer below with floor, and round up to the integer above with ceil.

Parameters
Return
Python

In Python, round() is the language's built-in function and uses banker's rounding: halfway values are rounded to the nearest even number. round(2.5) is therefore 2 and round(0.5) is 0, where LeekScript and JavaScript give 3 and 1; round(3.5) is indeed 4. To get LeekScript's rounding, write math.floor(x + 0.5). A second argument, which round does not have in LeekScript, sets the number of decimals: round(2.675, 2) is 2.67.

Examples

round(1) // 1 round(1.8) // 2 round(2.3) // 2 round(3.5) // 4 round(-12.79) // -13

See also