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