round
The round function converts a number or 1-dimensional array of numbers to the nearest integer.
rounded_numbers = round( numbers ) where numbers is a 1-dimensional array of numbers to be rounded. rounded_numbers is the table or number after rounding. |
The number x is rounded to integer n if (n – 0.5) <= x < (n + 0.5). Half integers n+0.5 are rounded up or down in the standard way to avoid statistical bias.
The following script lists the rounded values of several numbers in the range -3 through +3. Particular cases involving the odd/even rounding bias correction are notes as comments.
|
-- create a table to hold the values |
|
|
|
|
|
-- should round up to -2 |
|
|
|
|
|
|
|
-- should round down to -2 |
|
|
|
|
|
|
|
-- should round up to 0 |
|
|
|
|
|
|
|
-- should round down to 0 |
|
|
|
|
|
|
|
-- should round up to 2 |
|
|
|
|
|
|
|
-- should round down to 2 |
|
|
|
|
|
|
|
-- list all table array elements |
|
|
|
|
Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024
Mirametrics, Inc. All Rights Reserved.