@tempots/std
nearZero() function
nearZero
finds if the passed number is zero or very close to it. By default EPSILON
is used as the tollerance value.
Signature:
nearZero: (n: number, tollerance?: number) => boolean
Parameters
Parameter |
Type |
Description |
---|---|---|
n |
number |
The number to check. |
tollerance |
number |
(Optional) The tollerance value. Default is |
Returns: boolean
true
if the number is zero or very close to it, false
otherwise.
Example
nearZero(0.000000000000001) // returns true
nearZero(0.000000001) // returns false
nearZero(0.000000001, 1e-9) // returns true