Operator Type:
Operator Scope of Action:
Operator Purpose:
Operator First Added:
Operator Altered:
Function [other Function type actions]
Item [operators of similar scope]
Mathematical [other Mathematical operators]
Baseline
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 literal 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.