roundNumber := round_number(Args{
number: 3.14159,
mode: "Round",
digits: 0,
})
send_text_message(Args{channel_id: trigger.channel_id, message_content: "Result: " + roundNumber})
Round Number
BlockMath
Round a number using a chosen method (round, floor, ceil, truncate) to a specified number of digits.
Inputs
NumberRequired
Number to round.
Example: 3.14159
ModeRequired
Rounding method to use.
OptionsRoundFloorCeilTruncate
DigitsRequired
Number of digits to round to. Positive for decimals, negative for tens/hundreds/etc. E.g. 1 → 3.1, 0 → 3, -1 → 1250.
Example: 0
Outputs
Result
Rounded number.
Example: 3
Build a bot using blocks like Round Number
Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.
Advanced Documentation
This documentation can be useful when using code mode. View as Markdown
ID:
round_number- Value block: it can be used directly inside expressions, e.g.
"Result: " + round_number(Args{...}).
Inputs
| Field | InventScript name | Value |
|---|---|---|
| Number | number | e.g. "3.14159" |
| Mode | mode | "Round", "Floor", "Ceil", "Truncate" |
| Digits | digits | e.g. "0" |
Outputs
| Field | InventScript name | Value |
|---|---|---|
| Result | result | e.g. "3" |
Example InventScript
More math blocks
Math OperationsPerform addition, subtraction, multiplication, division, modulo and exponent operations.Math Operations (Float)Perform addition, subtraction, multiplication, division, modulo and exponent operations with floating point numbers.Absolute ValueGet the absolute value of a number.Square RootGet the square root (sqrt) of a number.LogarithmGet the logarithm of a number with a specified base.FactorialCalculate the factorial of a number.Random Number GeneratorGenerate a random number using specified minimum and maximum values.Passphrase GeneratorGenerate a random passphrase with a specified number of words.If Number is in RangeCheck if a number is in a specified range.If Number is Close to Other NumberCheck if a number is close to another number within a specified tolerance.If Value is NumberCheck if a value is a number.Hex to IntConvert a hexadecimal number to an integer.Int to HexConvert an integer to a hexadecimal number.Percentage Math (Integer)Add or subtract a percentage to/from an integer.Percentage Math (Float)Add or subtract a percentage to/from a floating point number.