Skip to content

Modern Math RoundHalfEven

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

Home › Math Library › Math Library › RoundHalfEven

RoundHalfEven

Rounds to the nearest whole number or number of decimals, halves to the even side.

Syntax

RoundHalfEven( x )
RoundHalfEven( x, digits )

Notes

  • banker's: — 2.5 -> 2, — -2.5 -> -2

Examples

#import "std/numeric"
using numeric

'' BANKER'S ROUNDING: a half goes to the EVEN neighbour, so a long run
'' of halves does not drift upwards the way half-away-from-zero does
print RoundHalfEven( 2.5 )   '' 2
print RoundHalfEven( 3.5 )   '' 4
print RoundHalfEven( -2.5 )  '' -2

'' This is the IEEE default and what the FPU already does
print Round( 2.5 )           '' 3 -- the other rule, for comparison

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

Clone this wiki locally