User Tools

Site Tools


4rpl:commands:approximately

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
4rpl:commands:approximately [2021/12/13 19:55] – linkfix Karsten754rpl:commands:approximately [2024/09/11 15:59] (current) – Placed note to clarify that this is for epsilon values, not a general margin Vertu
Line 1: Line 1:
 ~~NOTOC~~ ~~NOTOC~~
-<=[[4rpl:start| Index]]+<=[[4rpl:start| Index]] \\ 
 +<= [[4rpl:start#Math]]  
  
 ====== approximately ====== ====== approximately ======
Line 8: Line 9:
 Compares two floating point values and returns true if they are similar. Compares two floating point values and returns true if they are similar.
  
-Floating point imprecision makes comparing floats using the equals operator inaccurate. For example, (1.0 == 10.0 / 10.0) might not return true every time. Approximately() compares two floats and returns true if they are within a small value (Epsilon*) of each other.+Floating point imprecision makes comparing floats using the equals operator inaccurate. For example, (1.0 == 10.0 / 10.0) might not return true every time. Approximately() compares two floats and returns true if they are within a small value (//Epsilon//((Epsilon is defined as: The smallest value that a float can have different from zero.))) of each other.
  
 See [[https://docs.unity3d.com/Documentation/ScriptReference/Mathf.Approximately.html | Mathf.Approximately in Unity3D documentation]] See [[https://docs.unity3d.com/Documentation/ScriptReference/Mathf.Approximately.html | Mathf.Approximately in Unity3D documentation]]
  
-*Epsilon is defined as: The smallest value that a float can have different from zero.+If you came to this documentation for an API to handle an approximation that's much larger than (//Epsilon//((Epsilon is defined as: The smallest value that a float can have different from zero.))), such as comparing 1.625002 to 1.625000, an alternative is to use [[4rpl:commands:distance|Distance]] and define your own approximation margin.
  
 ===== Examples ===== ===== Examples =====
4rpl/commands/approximately.1639443329.txt.gz · Last modified: 2021/12/13 19:55 by Karsten75