approx and deepApprox to safely compare numbers
- Lingua principale
- JavaScript
- Stelle
- 1.9k
- Fork
- 359
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Testing equallity of numbers is a tricky business because of possible round of errors in floating point numbers. For example the following test will unexpectedly fail as the result of the left expression is `0.22000000000000003` and not `0.22`.
``` js
test.equal(2.2 / 10, 0.22);
```
It would be great to have functions like `approx` and `deepApprox` to safely compare numbers and objects/arrays containing numbers against each other. The function should compare whether the difference between the two numbers is at least a predefined factor epsilon smaller than the values itself (I guess there will be some edge cases when one of the values is zero, NaN, or Inf).
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.