fabs2.js 1.1 KB

1234567891011121314151617181920212223242526
  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. /*
  6. This file is executed from fabs1.js
  7. fabs from ucrtbase.dll doesn't restore the FPU Control word correctly when passed a NaN.
  8. This is exposed if we WScript.LoadScriptFile() code with Math.Abs(NaN) in it.
  9. Causing an assertion failure in SmartFPUControl. The change special-handles NaN without calling fabs
  10. */
  11. function testOp(av) {
  12. return Math.abs(av);
  13. }
  14. WScript.Echo(testOp(123.334) === 123.334);
  15. WScript.Echo(testOp(-123.334) === 123.334);
  16. WScript.Echo(isNaN(testOp(NaN)));
  17. WScript.Echo(isNaN(testOp(-NaN)));
  18. WScript.Echo(testOp(Infinity) === Infinity);
  19. WScript.Echo(testOp(-Infinity) === Infinity);
  20. WScript.Echo(testOp(0.0) === 0.0);
  21. WScript.Echo(testOp(-0.0) === 0.0);