User Tools

Site Tools


4rpl:commands:approximately

This is an old revision of the document!


Index

approximately

approximately(<-val1 <-val2)

Description

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.

See Mathf.Approximately in Unity3D documentation

*Epsilon is defined as: The smallest value that a float can have different from zero.

Examples

if (approximately(1.000001 1))
    trace("1.000001 is approximately equal to 1")
endif

Index

4rpl/commands/approximately.1610121708.txt.gz · Last modified: 2021/01/08 11:01 by 127.0.0.1