Skip to content

IsAlmost

Name - Description Default Type
<input> The input can be of any number type or a sequence of such types. FloatFloat2Float3Float4IntInt2Int3Int4Int8Int16[ Any ]
<output> true if the input is almost equal to the given value; otherwise, false. Bool
Value The value to test against for almost equality. None FloatFloat2Float3Float4IntInt2Int3Int4Int8Int16[ Any ]
Threshold The smallest difference to be considered equal. Should be greater than zero. 1.19209e-07 FloatInt

Checks whether the input is almost equal to a given value.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
;; integer comparison
199 (Math.Add 300) (IsAlmost 500 :Threshold 1)
(Assert.Is true :Abort true)

;; float comparison
4.0 (IsAlmost (+ 0.9999 3.0) :Threshold 0.0001)
(Assert.Is true :Abort true)

;; sequence comparison
[1 2 3.14] (IsAlmost [1 2 3.14])
(Assert.Is true :Abort true)