atan.js 1.1 KB

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