Skip to content

Modern Math Round

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Math Library › Math Library › Round

Round

Rounds to the nearest whole number or number of decimals, halves away from zero.

Syntax

Round( x )
Round( x, digits )

Notes

  • half away from zero: — 2.5 -> 3, — -2.5 -> -3
  • 0..17 decimal places

Examples

#import "std/numeric"
using numeric

'' HALF AWAY FROM ZERO -- the school rule, and NOT what the CPU does
print Round( 2.5 )           '' 3
print Round( -2.5 )          '' -3
print Round( 2.4 )           '' 2

'' RoundHalfEven is the banker's rule, and is what the hardware uses by
'' default -- so the two disagree on exactly the halves
print RoundHalfEven( 2.5 )   '' 2

Library: Math Library
Category: Math Library
Documented under: Nothing Becomes A Keyword

Clone this wiki locally