Equal Numbers: Difference between revisions

From Fancade Wiki
(Adapted "How to determine if a number is valid, NaN or Inf?" article from old wiki)
m (Include more relevant blocks)
 
(2 intermediate revisions by 2 users not shown)
Line 22: Line 22:
: [[File:precise-equals.jpg|thumb|none|Does not have the same issue as the example above]]
: [[File:precise-equals.jpg|thumb|none|Does not have the same issue as the example above]]


* You can check whether a number is valid by checking whether it is equal to itself. <code>nan</code>, <code>inf</code> or <code>-inf</code> are not considered equal to themselves because they represent a set of numbers.
* You can check whether a number is valid by checking whether it is equal to itself. <code>nan</code>, <code>inf</code> and <code>-inf</code> are not considered equal to themselves because they represent a set of numbers.
: [[File:Equal_nan_inf.png|thumb|none|NaN and Infinity are not equal to themselves]]
: [[File:Equal_nan_inf.png|thumb|none|NaN and Infinity are not equal to themselves]]


== Related ==
* [[Less Than]]
* [[Greater Than]]
* [[Equal Vectors]]
* [[Equal Truths]]
* [[Equal Objects]]


[[Category:Blocks]]
[[Category:Blocks]]

Latest revision as of 13:48, 29 July 2025

Equal Numbers
Equal Numbers.png
TypeScript block
ColliderNone
FolderMath
Ports
Inputs Num1
Num2
Outputs Num1 = Num2

Outputs True if both number inputs are equal, and false if they are not.

Example
Example

Notes

  • The numbers do not have to be actually equal to be considered equal, they have to be close enough.
0.001 is equal to 0
If high precision is required, the following script can be used:
Does not have the same issue as the example above
  • You can check whether a number is valid by checking whether it is equal to itself. nan, inf and -inf are not considered equal to themselves because they represent a set of numbers.
NaN and Infinity are not equal to themselves

Related