round

The rounding used in the following is called the bankers’ rounding.

round(a: number) 🡒 number, pure function

Rounds a number to the nearest even number.

Example:

show table "" a1a3 with
  round(0.5) // 0
  round(1.5) // 2
  round(4.5) // 4

Calling round(x) or round(x, 0) (see below) gives identical results.

round(a: number, b : number) 🡒 number, pure function

Rounds a number to the nearest even number, considering the number of digits that are intended to be kept, passed as a second argument.

Example:

show table "" a1a3 with
  round(4.33, 0) // 4
  round(4.33, 1) // 4.3
  round(4.33, 2) // 4.33

The second argument must be an integer between 0 and 15 (inclusive), otherwise the function will fail.