log.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // interesting floating point limits
  6. checkNaN(NaN);
  7. checkNaN(-4);
  8. check(-Infinity, +0);
  9. check(-Infinity, -0.0);
  10. check(0, 1);
  11. check(+Infinity, +Infinity);
  12. check(3, Math.E*Math.E*Math.E);
  13. if(!isNaN(Math.log()))
  14. {
  15. WScript.Echo("error: Math.log() is not NaN");
  16. }
  17. WScript.Echo("done");
  18. function check(result, n) {
  19. var rs = Math.log(n);
  20. if ( Math.abs(rs - result) > 0.00000000001) {
  21. WScript.Echo("log(" + n + ") != " + result);
  22. WScript.Echo(" wrong result is log(" + n + ") = " + rs);
  23. }
  24. }
  25. function checkNaN(x) {
  26. var rs = Math.log(x);
  27. if (!isNaN(rs)) {
  28. WScript.Echo("log(" + x + ") != NaN");
  29. WScript.Echo(" wrong result is log(" + x + ") = " + rs);
  30. }
  31. }