tan.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. check(+0, +0);
  8. check(-0.0, -0.0);
  9. checkNaN(+Infinity);
  10. checkNaN(-Infinity);
  11. check(1, (Math.PI) /4);
  12. if(!isNaN(Math.tan()))
  13. {
  14. WScript.Echo("error: Math.tan() is not NaN");
  15. }
  16. WScript.Echo("done");
  17. function check(result, n) {
  18. var rs = Math.tan(n);
  19. if (Math.abs(rs - result) > 0.00000000001) {
  20. WScript.Echo("tan(" + n + ") != " + result);
  21. WScript.Echo(" wrong result is tan(" + n + ") = " + rs);
  22. }
  23. }
  24. function checkNaN(x) {
  25. var rs = Math.tan(x);
  26. if (!isNaN(rs)) {
  27. WScript.Echo("tan(" + x + ") != NaN");
  28. WScript.Echo(" wrong result is tan(" + x + ") = " + rs);
  29. }
  30. }