sin.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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) /2);
  12. check(0.5 , (Math.PI) / 6);
  13. if(!isNaN(Math.sin()))
  14. {
  15. WScript.Echo("error: Math.sin() is not NaN");
  16. }
  17. WScript.Echo("done");
  18. function check(result, n) {
  19. var rs = Math.sin(n);
  20. if (Math.abs(rs - result) > 0.00000000001) {
  21. WScript.Echo("sin(" + n + ") != " + result);
  22. WScript.Echo(" wrong result is sin(" + n + ") = " + rs);
  23. }
  24. }
  25. function checkNaN(x) {
  26. var rs = Math.sin(x);
  27. if (!isNaN(rs)) {
  28. WScript.Echo("sin(" + x + ") != NaN");
  29. WScript.Echo(" wrong result is sin(" + x + ") = " + rs);
  30. }
  31. }