approx and deepApprox to safely compare numbers
- Lenguaje dominante
- JavaScript
- Estrellas
- 1.9k
- Forks
- 359
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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).
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Empieza revisando la API de comparación existente de nodeunit basada en assert. Define cómo deben comparar approx y deepApprox los números, objetos y arrays, incluido el comportamiento de epsilon indicado y los casos límite para cero, NaN e Infinity. Se considera terminado cuando las funciones y sus comparaciones esperadas estén especificadas y cubiertas por pruebas.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- testing-qa
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 25/100