Math-constants.js 492 B

1234567891011121314151617
  1. // Borrowed from LibM/TestMath.cpp :^)
  2. function expectClose(a, b) { assert(Math.abs(a - b) < 0.000001); }
  3. try {
  4. expectClose(Math.E, 2.718281);
  5. expectClose(Math.LN2, 0.693147);
  6. expectClose(Math.LN10, 2.302585);
  7. expectClose(Math.LOG2E, 1.442695);
  8. expectClose(Math.LOG10E, 0.434294);
  9. expectClose(Math.PI, 3.1415926);
  10. expectClose(Math.SQRT1_2, 0.707106);
  11. expectClose(Math.SQRT2, 1.414213);
  12. console.log("PASS");
  13. } catch (e) {
  14. console.log("FAIL: " + e);
  15. }