approx and deepApprox to safely compare numbers
- 主要言語
- JavaScript
- スター
- 1.9k
- フォーク
- 359
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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).
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まず、nodeunit の既存の assert ベースの比較 API を確認します。approx と deepApprox が数値、オブジェクト、配列をどのように比較するかを、指定された epsilon の挙動と、ゼロ、NaN、Infinity のエッジケースを含めて定義します。関数とそれらに期待される比較が仕様化され、テストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- testing-qa
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100