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

FieldInventScript nameValue
Number 1number_1e.g. "10"
Number 2number_2e.g. "10.2"
Tolerancetolerancee.g. "0.5"
If Trueif_trueblocks: func() { ... }
If Falseif_falseblocks: func() { ... }

Outputs

FieldInventScript nameValue
Resultresulte.g. "true"

Example InventScript

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"})
}

More math blocks