asin.js 1.1 KB

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