Equal Numbers: Difference between revisions

Adapted "How to determine if a number is valid, NaN or Inf?" article from old wiki
m (Add information, adapted from old wiki article, and Related section)
(Adapted "How to determine if a number is valid, NaN or Inf?" article from old wiki)
Line 14: Line 14:
== Notes ==
== Notes ==


The numbers do not have to be actually equal to be considered equal, they have to be ''close enough''.
* The numbers do not have to be actually equal to be considered equal, they have to be ''close enough''.


[[File:Equal-not-precise.jpg|thumb|none|0.001 is equal to 0]]
: [[File:Equal-not-precise.jpg|thumb|none|0.001 is equal to 0]]


If high precision is required, the following script can be used:
: If high precision is required, the following script can be used:


[[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]]


If one of the inputs are <code>NaN</code> or <code>inf</code> the block returns <code>False</code> regardless of sameness.
* 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.
: [[File:Equal_nan_inf.png|thumb|none|NaN and Infinity are not equal to themselves]]


== Related ==
* [[Equal Vectors]]
* [[Equal Truths]]


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