if if_number_close_to_other_number(Args{
number_1: 10,
number_2: 10.2,
tolerance: 0.5,
}) {
send_text_message(Args{channel_id: trigger.channel_id, message_content: "Yes"})
}
If Number is Close to Other Number
ConditionMath
Check if a number is close to another number within a specified tolerance.
- Condition block: the blocks placed inside it only run when the condition is met.
Inputs
Number 1Required
First number.
Example: 10
Number 2Required
Second number.
Example: 10.2
ToleranceRequired
Inclusive tolerance between the numbers.
Example: 0.5
If True
Blocks to run when the numbers are close.
Holds blocks
If False
Blocks to run when the numbers are not close.
Holds blocks
Outputs
Result
Whether the numbers are within tolerance.
Example: true
Build a bot using blocks like If Number is Close to Other 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:
if_number_close_to_other_number- Condition block: write
if if_number_close_to_other_number(Args{...}) { ... }, or use it as a"true"/"false"value. See conditions.
Inputs
| Field | InventScript name | Value |
|---|---|---|
| Number 1 | number_1 | e.g. "10" |
| Number 2 | number_2 | e.g. "10.2" |
| Tolerance | tolerance | e.g. "0.5" |
| If True | if_true | blocks: func() { ... } |
| If False | if_false | blocks: func() { ... } |
Outputs
| Field | InventScript name | Value |
|---|---|---|
| Result | result | e.g. "true" |
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.Round NumberRound a number using a chosen method (round, floor, ceil, truncate) to a specified number of digits.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 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.