Round Controlled
Rounds a number with options
Parameters
- Number - Number to be rounded
- Directions - Direction of rounding
- Decimals - How many decimal places
Parameters in Detail
Number
The first parameter is a number that you wish to round. This number can be entered directly into the command, or from another location such as a spreadsheet or a global numerical variable.
Direction
The second parameter chooses the direction of rounding. There are five options:
- Nearest
- Smaller
- Larger
- Down
- Up
The difference between “Smaller” and “Down” comes when the values are negative:
2.4 down = 2
2.4 smaller = 2
-2.4 down = -3
-2.4 smaller = -2
Decimals
The third parameter is number of decimals to begin the rounding position.
Examples
Example 1
On End Run Logic
SET gblNumber = 123.456
Round Controlled gblNumber , Nearest , 2
The above example will convert 123.456 (from the variable gblNumber) to 123.46
Example 2
On End Run Logic
SET gblNumber = 123.456
Round Controlled gblNumber , Down , 1
The above example will convert 123.456 (from the variable gblNumber) to 123.4
Example 3
On End Run Logic
SET gblNumber = 123.456
Round Controlled gblNumber , Up , 0
The above example will convert 123.456 (from the variable gblNumber) to 124
Example 4
On End Run Logic
SET gblNumber = 123.456
Round Controlled gblNumber , Larger , 2
The above example will convert 123.456 (from the variable gblNumber) to 123.46
Comments
This command is only available with Simul8 Professional 2017 and later.