Skip to content
ffredyk edited this page Jul 23, 2026 · 1 revision

round

Category

Math

Arity

Unaryround <number>.

round <number>

Description

Rounds a number to the nearest integer. Midpoint values (.5) round to the nearest even number (banker's rounding). round 3.54, round 2.52. Auto-unwraps shared values.

How It Works

Calls Math.Round(double, MidpointRounding.ToEven). This is the .NET default rounding strategy — also called "banker's rounding." It avoids statistical bias from always rounding .5 up.

Usage

round 3.2;                     // 3
round 3.7;                     // 4
round 3.5;                     // 4 (nearest even)
round 2.5;                     // 2 (nearest even)
round -1.5;                    // -2

// Snap to integer
_snapped = round _value;

// Percentage display
_pct = round (_score / _max * 100);

Note: Midpoint rounding to even differs from Arma SQF which rounds .5 up. If you need always-round-.5-up behavior, use floor (_x + 0.5) for positive numbers.

Thread Safety

ReadOnly — pure computation. Safe from any scheduler.

See Also

  • floor — round down
  • ceil — round up
  • abs — absolute value

SQ# Wiki

Home

Engine Docs

Migration

Commands

Value Constructors

Arithmetic

Comparison

Logic

Array

String

Math

Random

Type & Introspection

HashMap

Code Execution

Concurrency

Scheduler

Thread Safety

Error

Output

Time

Multiplayer

Compiler

Clone this wiki locally