This version is out of date, covering development from v5.0.0 to v5.12.2. It is maintained here only for inbound reference links from elsewhere.

# round(argument)

Operator Type:

Operator Scope of Action:

Operator Purpose:

Operator Altered:

Function   [other Function type actions]

Item   [operators of similar scope]

Mathematical   [other Mathematical operators]

round(argument)

round() rounds the value of its argument to the nearest integer.

The Number.format, Number.precision and format() functions all round numbers in this manner when shortening numbers during formatting. A partial integer over .50 always round up, everything else rounds down. Thus:

`\$MyNumber = round(4.0)` gives 4

`\$MyNumber = round(4.2)` gives 4

`\$MyNumber = round(4.5)` gives 5

`\$MyNumber = round(4.7)` gives 5

The round function with work on string litteral or String attribute values that are just numbers:

`\$MyNumber = round("4.2")` gives 4

`\$MyNumber = round("4.7")` gives 5

`\$MyString = round(4.2)` gives "4"

`\$MyString = round(4.7)` gives "5"

`\$MyString = round("4.2")` gives "4"

`\$MyString = round("4.7")` gives "5"

There are no functions to always force a round down (floor) or up (ceiling), but these can be simulated with a bit of action code.

To always round down:

``````if(\$MyNum > 0){
\$MyNumA = round(\$MyNum-0.5);
}else{
\$MyNumA = round(\$MyNum+0.5);
}``````

And the reverse? To alway round a number up:

``````if(\$MyNum > 0){
\$MyNumA = round(\$MyNum+0.5);
}else{
\$MyNumA = round(\$MyNum-0.5);
}``````

In both the above, negative numbers move towards/away from zero in the same fashion as positive ones. Adjust the code for other types of rounding.

Possible relevant notes (via "Similar Notes" feature):

A Tinderbox Reference File : Actions & Rules : Operators : Full Operator List : round(argument)