Round the number Version 10 (Python)

Action group: Operators


Description

The action rounds the number.

Action icon

Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
NumberThe number to be rounded by.Robin.Numeric
Yes
Digit numberThe ordinal number of the digit of the number that will be rounded. The numbering starts from 1. The count starts from left to right.Robin.Numeric
Yes
Rounding methodThe parameter specifies the method by which the number will be roundedRobin.String
Yes
Results
The rounded numberNumber after rounding.Robin.Numeric

Special conditions of use

  1. The action works with the following rounding methods: rounding to the nearest whole, rounding to the greater, rounding to the lesser.
  2. For the action to work, you must enter the ordinal number of the digit of the number to be rounded. 
  3. If the number of the digit is specified greater than what is in the number - the action returns an unchanged number.
  4. If the digit sequence number value is specified as "0" or a negative number, the robot will return an error.
  5. After rounding the specified digit, all zeros after it are removed, but only if they are after the decimal point. Example: 2.486 → 2.49
  6. If the digit to be rounded is after the decimal point and rounded to a value of "0", the "0" will not be specified in the output number, but the value of the digit before it will be incremented by 1. Example: 2.99 → 3
  7. If the number after rounding has integer - 0 and zero values after the decimal point, the action will return "0". Example: The input number is "0.0012". The number of the digit to be rounded is 3. The number is rounded to "0.00". The action returns "0".

Round to nearest  - round to the nearest digit. See which digit is after the required digit, if 0 to 4, the number does not change, if 5 to 9, it becomes one more. Example: 2.1 → 2; -1.9 → -2; 2.5→ 3

Round up  -  round up to +∞. Example: 2.1 → 3 ;  -1.9 → -1

Round down - round down to −∞. Example: 2.1 → 2 ; -1.1 → -2

Action work example:

  • Input number: 349. Number of digit for rounding - 3, Rounding method - Rounding to the nearest whole. Output number: 349
  • Input number: 349. Number of digit for rounding - 2, Rounding method - Rounding to the nearest whole. Output number: 350
  • Input number: 3,489. Number of digit for rounding - 3, Rounding method - Rounding to the lesser. Output number: 3.48
  • Input number: -3.6. Number of digit for rounding - 1, Rounding method - Rounding to the greater. Output number: -3

Example of use

Task

Round the number 349 to the nearest number (the number of digits to be rounded is 2), display this number in the dialog box. 

Solution

Use the "Round the number", "Show message" actions.

Implementation

  1. Mose the "Round the number" action to the workspace.
  2. Set the "Round the number" action parameters.
  3. Set the "Show message" action parameters.
  4. Click "Start" in the top panel.

Result

The program robot completed successfully.

The final number after the rounding is 350. 


  • Нет меток