Сравнение версий

Ключ

  • Эта строка добавлена.
  • Эта строка удалена.
  • Изменено форматирование.

...

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
  8. Действие работает со следующими способами округления : округление к ближайшему целому, округление к большему, округление к меньшему.
  9. Для работы действия необходимо ввести порядковый номер цифры числа, который будет округляться. 
  10. Если номер цифры указан больше того, что есть в числе - действие возвращает неизмененное число.
  11. Если значение порядкового номера цифры указано "0" или отрицательное число, то робот вернет ошибку.
  12. После округления указанной цифры, все нули после него удаляются, но только если они находятся после запятой. Пример: 2.486 → 2.49
  13. Если округляемая цифра находится после запятой и округляется до значения "0", то "0" не будет указан в выходном числе, а значение цифры перед ним увеличиться на 1. Пример: 2.99 → 3
  14. Если у числа после округления целое - 0 и после запятой идут нулевые значения, то действие вернет "0".Пример: На входе число "0.0012". Номер цифры для округления - 3. Число округляется до "0.00". Действие возвращает "0".

Round to nearest  - округление до ближайшей цифры. Необходимо посмотреть какая цифра находится после необходимого, если от 0 до 4, то число не изменяется, если от 5 до 9, то оно становится на один больше. Пример: 2.1 → 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, Способ округления - Округление к меньшему. Число на выходе: 3,48
  • Число на входе: -3,6. Номер цифры для округления - 1, Способ округления - Округление к большему. Число на выходе: -3

Пример использования 

Задача

Округлить число 349 к ближайшему (номер цифры для округления - 2), вывести данное число в диалоговое окно. 

Решение

Воспользоваться действием "Округлить число" и "Show message".

Реализация

  1. Перенести на рабочую область действие "Округлить число". 
    Image Removed
  2. Настроить параметры действия "Округлить число". 
    Image Removed
  3. Настроить параметры действия "Show message". 
    Image Removed
  4. Нажать на кнопку "Старт" в верхней панели. 

Результат

Программный робот отработал успешно.

Image Removed

  • 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.
    Image Added
  2. Set the "Round the number" action parameters.
    Image Added
  3. Set the "Show message" action parameters.
    Image Added
  4. Click "Start" in the top panel.

Result

The program robot completed successfully.

Image Added

The final number after the rounding is В результате число после округления -  350.