Browse the docs

round

Rounds a number to a whole number or to a number of decimal places.

Keyboard Maestro: round

Details #

round(number, places?) takes one or two arguments and returns a number. Numeric text is accepted.

  • With one argument it rounds to a whole number. A half rounds away from zero: round(2.5) is 3 and round(-2.5) is -3.

  • A positive places keeps that many decimals: round(3.14159, 2) is 3.14.

  • A negative places rounds to tens, hundreds and so on: round(1234, -2) is 1200.

Parameters #

Takes 1 to 2 arguments. {{ round(text, b?) }}

Examples #

round(2.5)
→ 3
round(3.14159, 2)
→ 3.14
round(1234, -2)
→ 1200

Gotchas #

  • Anything that isn't a number is an error: round() needs a number, got text.

  • Results are floating point, so round(0.1 + 0.2, 2) is the safe way to get 0.3.