Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** sections of test262 that cover number precision
- "S11": "5.1.A4: T1-T8",
- "S15": {
- "7": "3: 2.A1 & 3.A1",
- "8": {
- "1": "1-8: A1",
- "2": {
- "4": "A4 & A5",
- "5": "A: 3,6,7,10-13,15,17-19",
- "7": "A6 & A7",
- "13": "A24",
- "16": "A6 & A7",
- "17": "A6",
- "18": "A6"
- }
- }
- },
- "S8": "5.A2: 1 & 2"
- SOURCES OF SAID SECTIONS: (in no specific order)
- **/
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * The result of a floating-point multiplication is governed by the rules of IEEE 754 double-precision arithmetics
- *
- * @path ch11/11.5/11.5.1/S11.5.1_A4_T1.1.js
- * @description If left operand is NaN, the result is NaN
- */
- //CHECK#1
- if (isNaN(Number.NaN * Number.NaN) !== true) {
- $ERROR('#1: NaN * NaN === Not-a-Number. Actual: ' + (NaN * NaN));
- }
- //CHECK#2
- if (isNaN(Number.NaN * +0) !== true) {
- $ERROR('#2: NaN * +0 === Not-a-Number. Actual: ' + (NaN * +0));
- }
- //CHECK#3
- if (isNaN(Number.NaN * -0) !== true) {
- $ERROR('#3: NaN * -0 === Not-a-Number. Actual: ' + (NaN * -0));
- }
- //CHECK#4
- if (isNaN(Number.NaN * Number.POSITIVE_INFINITY) !== true) {
- $ERROR('#4: NaN * Infinity === Not-a-Number. Actual: ' + (NaN * Infinity));
- }
- //CHECK#5
- if (isNaN(Number.NaN * Number.NEGATIVE_INFINITY) !== true) {
- $ERROR('#5: NaN * -Infinity === Not-a-Number. Actual: ' + (NaN * -Infinity));
- }
- //CHECK#6
- if (isNaN(Number.NaN * Number.MAX_VALUE) !== true) {
- $ERROR('#6: NaN * Number.MAX_VALUE === Not-a-Number. Actual: ' + (NaN * Number.MAX_VALUE));
- }
- //CHECK#7
- if (isNaN(Number.NaN * Number.MIN_VALUE) !== true) {
- $ERROR('#7: NaN * Number.MIN_VALUE === Not-a-Number. Actual: ' + (NaN * Number.MIN_VALUE));
- }
- //CHECK#8
- if (isNaN(Number.NaN * 1) !== true) {
- $ERROR('#8: NaN * 1 === Not-a-Number. Actual: ' + (NaN * 1));
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * The result of a floating-point multiplication is governed by the rules of IEEE 754 double-precision arithmetics
- *
- * @path ch11/11.5/11.5.1/S11.5.1_A4_T1.2.js
- * @description If right operand is NaN, the result is NaN
- */
- //CHECK#1
- if (isNaN(Number.NaN * Number.NaN) !== true) {
- $ERROR('#1: NaN * NaN === Not-a-Number. Actual: ' + (NaN * NaN));
- }
- //CHECK#2
- if (isNaN(+0 * Number.NaN) !== true) {
- $ERROR('#2: +0 * NaN === Not-a-Number. Actual: ' + (+0 * NaN));
- }
- //CHECK#3
- if (isNaN(-0 * Number.NaN) !== true) {
- $ERROR('#3: -0 * NaN === Not-a-Number. Actual: ' + (-0 * NaN));
- }
- //CHECK#4
- if (isNaN(Number.POSITIVE_INFINITY * Number.NaN) !== true) {
- $ERROR('#4: Infinity * NaN === Not-a-Number. Actual: ' + (Infinity * NaN));
- }
- //CHECK#5
- if (isNaN(Number.NEGATIVE_INFINITY * Number.NaN) !== true) {
- $ERROR('#5: -Infinity * NaN === Not-a-Number. Actual: ' + ( -Infinity * NaN));
- }
- //CHECK#6
- if (isNaN(Number.MAX_VALUE * Number.NaN) !== true) {
- $ERROR('#6: Number.MAX_VALUE * NaN === Not-a-Number. Actual: ' + (Number.MAX_VALUE * NaN));
- }
- //CHECK#7
- if (isNaN(Number.MIN_VALUE * Number.NaN) !== true) {
- $ERROR('#7: Number.MIN_VALUE * NaN === Not-a-Number. Actual: ' + (Number.MIN_VALUE * NaN));
- }
- //CHECK#8
- if (isNaN(1 * Number.NaN) !== true) {
- $ERROR('#8: 1 * NaN === Not-a-Number. Actual: ' + (1 * NaN));
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * The result of a floating-point multiplication is governed by the rules of IEEE 754 double-precision arithmetics
- *
- * @path ch11/11.5/11.5.1/S11.5.1_A4_T2.js
- * @description The sign of the result is positive if both operands have the same sign, negative if the operands have different signs
- */
- //CHECK#1
- if (1 * 1 !== 1) {
- $ERROR('#1: 1 * 1 === 1. Actual: ' + (1 * 1));
- }
- //CHECK#2
- if (1 * -1 !== -1) {
- $ERROR('#2: 1 * -1 === -1. Actual: ' + (1 * -1));
- }
- //CHECK#3
- if (-1 * 1 !== -1) {
- $ERROR('#3: -1 * 1 === -1. Actual: ' + (-1 * 1));
- }
- //CHECK#4
- if (-1 * -1 !== 1) {
- $ERROR('#4: -1 * -1 === 1. Actual: ' + (-1 * -1));
- }
- //CHECK#5
- if (0 * 0 !== 0) {
- $ERROR('#5.1: 0 * 0 === 0. Actual: ' + (0 * 0));
- } else {
- if (1 / (0 * 0) !== Number.POSITIVE_INFINITY) {
- $ERROR('#5.2: 0 * 0 === + 0. Actual: -0');
- }
- }
- //CHECK#6
- if (0 * -0 !== -0) {
- $ERROR('#6.1: 0 * -0 === 0. Actual: ' + (0 * -0));
- } else {
- if (1 / (0 * -0) !== Number.NEGATIVE_INFINITY) {
- $ERROR('#6.2: 0 * -0 === - 0. Actual: +0');
- }
- }
- //CHECK#7
- if (-0 * 0 !== -0) {
- $ERROR('#7.1: -0 * 0 === 0. Actual: ' + (-0 * 0));
- } else {
- if (1 / (-0 * 0) !== Number.NEGATIVE_INFINITY) {
- $ERROR('#7.2: -0 * 0 === - 0. Actual: +0');
- }
- }
- //CHECK#8
- if (-0 * -0 !== 0) {
- $ERROR('#8.1: -0 * -0 === 0. Actual: ' + (-0 * -0));
- } else {
- if (1 / (-0 * -0) !== Number.POSITIVE_INFINITY) {
- $ERROR('#8.2: 0 * -0 === - 0. Actual: +0');
- }
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * The result of a floating-point multiplication is governed by the rules of IEEE 754 double-precision arithmetics
- *
- * @path ch11/11.5/11.5.1/S11.5.1_A4_T3.js
- * @description Multiplication of an infinity by a zero results in NaN
- */
- //CHECK#1
- if (isNaN(Number.NEGATIVE_INFINITY * 0) !== true) {
- $ERROR('#1: Infinity * 0 === Not-a-Number. Actual: ' + (Infinity * 0));
- }
- //CHECK#2
- if (isNaN(-0 * Number.NEGATIVE_INFINITY) !== true) {
- $ERROR('#2: -0 * -Infinity === Not-a-Number. Actual: ' + (-0 * -Infinity));
- }
- //CHECK#3
- if (isNaN(Number.POSITIVE_INFINITY * -0) !== true) {
- $ERROR('#3: Infinity * -0 === Not-a-Number. Actual: ' + (Infinity * -0));
- }
- //CHECK#4
- if (isNaN(0 * Number.POSITIVE_INFINITY) !== true) {
- $ERROR('#4: 0 * Infinity === Not-a-Number. Actual: ' + (0 * Infinity));
- }
- //CHECK#5
- if (isNaN(Number.NEGATIVE_INFINITY * -0) !== true) {
- $ERROR('#5: Infinity * -0 === Not-a-Number. Actual: ' + (Infinity * -0));
- }
- //CHECK#6
- if (isNaN(0 * Number.NEGATIVE_INFINITY) !== true) {
- $ERROR('#6: 0 * -Infinity === Not-a-Number. Actual: ' + (0 * -Infinity));
- }
- //CHECK#7
- if (isNaN(Number.POSITIVE_INFINITY * 0) !== true) {
- $ERROR('#7: Infinity * 0 === Not-a-Number. Actual: ' + (Infinity * 0));
- }
- //CHECK#8
- if (isNaN(-0 * Number.POSITIVE_INFINITY) !== true) {
- $ERROR('#8: -0 * Infinity === Not-a-Number. Actual: ' + (-0 * Infinity));
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * The result of a floating-point multiplication is governed by the rules of IEEE 754 double-precision arithmetics
- *
- * @path ch11/11.5/11.5.1/S11.5.1_A4_T4.js
- * @description Multiplication of an infinity by an infinity results in an infinity of appropriate sign
- */
- //CHECK#1
- if (Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY !== Number.POSITIVE_INFINITY) {
- $ERROR('#1: -Infinity * -Infinity === Infinity. Actual: ' + (-Infinity * -Infinity));
- }
- //CHECK#2
- if (Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY !== Number.POSITIVE_INFINITY) {
- $ERROR('#2: Infinity * Infinity === Infinity. Actual: ' + (Infinity * Infinity));
- }
- //CHECK#3
- if (Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY !== Number.NEGATIVE_INFINITY) {
- $ERROR('#3: -Infinity * Infinity === -Infinity. Actual: ' + (-Infinity * Infinity));
- }
- //CHECK#4
- if (Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY !== Number.NEGATIVE_INFINITY) {
- $ERROR('#4: Infinity * -Infinity === -Infinity. Actual: ' + (Infinity * -Infinity));
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * The result of a floating-point multiplication is governed by the rules of IEEE 754 double-precision arithmetics
- *
- * @path ch11/11.5/11.5.1/S11.5.1_A4_T5.js
- * @description Multiplication of an infinity by a finite non-zero value results in a signed infinity
- */
- //CHECK#1
- if (Number.NEGATIVE_INFINITY * -1 !== Number.POSITIVE_INFINITY) {
- $ERROR('#1: -Infinity * -1 === Infinity. Actual: ' + (-Infinity * -1));
- }
- //CHECK#2
- if (-1 * Number.NEGATIVE_INFINITY !== Number.POSITIVE_INFINITY) {
- $ERROR('#2: -1 * -Infinity === Infinity. Actual: ' + (-1 * -Infinity));
- }
- //CHECK#3
- if (Number.POSITIVE_INFINITY * -1 !== Number.NEGATIVE_INFINITY) {
- $ERROR('#3: Infinity * -1 === -Infinity. Actual: ' + (Infinity * -1));
- }
- //CHECK#4
- if (-1 * Number.POSITIVE_INFINITY !== Number.NEGATIVE_INFINITY) {
- $ERROR('#4: -1 * Infinity === -Infinity. Actual: ' + (-1 * Infinity));
- }
- //CHECK#5
- if (Number.POSITIVE_INFINITY * Number.MAX_VALUE !== Number.POSITIVE_INFINITY) {
- $ERROR('#5: Infinity * Number.MAX_VALUE === Infinity. Actual: ' + (Infinity * Number.MAX_VALUE));
- }
- //CHECK#6
- if (Number.POSITIVE_INFINITY * Number.MAX_VALUE !== Number.MAX_VALUE * Number.POSITIVE_INFINITY) {
- $ERROR('#6: Infinity * Number.MAX_VALUE === Number.MAX_VALUE * Infinity. Actual: ' + (Infinity * Number.MAX_VALUE));
- }
- //CHECK#7
- if (Number.NEGATIVE_INFINITY * Number.MIN_VALUE !== Number.NEGATIVE_INFINITY) {
- $ERROR('#7: -Infinity * Number.MIN_VALUE === -Infinity. Actual: ' + (-Infinity * Number.MIN_VALUE));
- }
- //CHECK#8
- if (Number.NEGATIVE_INFINITY * Number.MIN_VALUE !== Number.MIN_VALUE * Number.NEGATIVE_INFINITY) {
- $ERROR('#8: -Infinity * Number.MIN_VALUE === Number.MIN_VALUE * -Infinity. Actual: ' + (-Infinity * Number.MIN_VALUE));
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * The result of a floating-point multiplication is governed by the rules of IEEE 754 double-precision arithmetics
- *
- * @path ch11/11.5/11.5.1/S11.5.1_A4_T6.js
- * @description If the magnitude is too large to represent, the result is then an infinity of appropriate sign
- */
- //CHECK#1
- if (Number.MAX_VALUE * 1.1 !== Number.POSITIVE_INFINITY) {
- $ERROR('#1: Number.MAX_VALUE * 1.1 === Number.POSITIVE_INFINITY. Actual: ' + (Number.MAX_VALUE * 1.1));
- }
- //CHECK#2
- if (-1.1 * Number.MAX_VALUE !== Number.NEGATIVE_INFINITY) {
- $ERROR('#2: -1.1 * Number.MAX_VALUE === Number.NEGATIVE_INFINITY. Actual: ' + (-1.1 * Number.MAX_VALUE));
- }
- //CHECK#3
- if (Number.MAX_VALUE * 1 !== Number.MAX_VALUE) {
- $ERROR('#3: Number.MAX_VALUE * 1 === Number.MAX_VALUE. Actual: ' + (Number.MAX_VALUE * 1));
- }
- //CHECK#4
- if (-1 * Number.MAX_VALUE !== -Number.MAX_VALUE) {
- $ERROR('#4: -1 * Number.MAX_VALUE === -Number.MAX_VALUE. Actual: ' + (-1 * Number.MAX_VALUE));
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * The result of a floating-point multiplication is governed by the rules of IEEE 754 double-precision arithmetics
- *
- * @path ch11/11.5/11.5.1/S11.5.1_A4_T7.js
- * @description If the magnitude is too small to represent, the result is then a zero of appropriate sign
- */
- //CHECK#1
- if (Number.MIN_VALUE * 0.1 !== 0) {
- $ERROR('#1: Number.MIN_VALUE * 0.1 === 0. Actual: ' + (Number.MIN_VALUE * 0.1));
- }
- //CHECK#2
- if (-0.1 * Number.MIN_VALUE !== -0) {
- $ERROR('#2.1: -0.1 * Number.MIN_VALUE === -0. Actual: ' + (-0.1 * Number.MIN_VALUE));
- } else {
- if (1 / (-0.1 * Number.MIN_VALUE) !== Number.NEGATIVE_INFINITY) {
- $ERROR('#2.2: -0.1 * Number.MIN_VALUE === -0. Actual: +0');
- }
- }
- //CHECK#3
- if (Number.MIN_VALUE * 0.5 !== 0) {
- $ERROR('#3: Number.MIN_VALUE * 0.5 === 0. Actual: ' + (Number.MIN_VALUE * 0.5));
- }
- //CHECK#4
- if (-0.5 * Number.MIN_VALUE !== -0) {
- $ERROR('#4.1: -0.5 * Number.MIN_VALUE === -0. Actual: ' + (-0.5 * Number.MIN_VALUE));
- } else {
- if (1 / (-0.5 * Number.MIN_VALUE) !== Number.NEGATIVE_INFINITY) {
- $ERROR('#4.2: -0.5 * Number.MIN_VALUE === -0. Actual: +0');
- }
- }
- //CHECK#5
- if (Number.MIN_VALUE * 0.51 !== Number.MIN_VALUE) {
- $ERROR('#5: Number.MIN_VALUE * 0.51 === Number.MIN_VALUE. Actual: ' + (Number.MIN_VALUE * 0.51));
- }
- //CHECK#6
- if (-0.51 * Number.MIN_VALUE !== -Number.MIN_VALUE) {
- $ERROR('#6: -0.51 * Number.MIN_VALUE === -Number.MIN_VALUE. Actual: ' + (-0.51 * Number.MIN_VALUE));
- }
- //CHECK#7
- if (Number.MIN_VALUE * 0.9 !== Number.MIN_VALUE) {
- $ERROR('#7: Number.MIN_VALUE * 0.9 === Number.MIN_VALUE. Actual: ' + (Number.MIN_VALUE * 0.9));
- }
- //CHECK#8
- if (-0.9 * Number.MIN_VALUE !== -Number.MIN_VALUE) {
- $ERROR('#8: -0.9 * Number.MIN_VALUE === -Number.MIN_VALUE. Actual: ' + (-0.9 * Number.MIN_VALUE));
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * The result of a floating-point multiplication is governed by the rules of IEEE 754 double-precision arithmetics
- *
- * @path ch11/11.5/11.5.1/S11.5.1_A4_T8.js
- * @description Multiplication is not always associative (x * y * z is the same as (x * y) * z, not x * (y * z))
- */
- //CHECK#1
- if (Number.MAX_VALUE * 1.1 * 0.9 !== (Number.MAX_VALUE * 1.1) * 0.9) {
- $ERROR('#1: Number.MAX_VALUE * 1.1 * 0.9 === (Number.MAX_VALUE * 1.1) * 0.9. Actual: ' + (Number.MAX_VALUE * 1.1 * 0.9));
- }
- //CHECK#2
- if ((Number.MAX_VALUE * 1.1) * 0.9 === Number.MAX_VALUE * (1.1 * 0.9)) {
- $ERROR('#2: (Number.MAX_VALUE * 1.1) * 0.9 !== Number.MAX_VALUE * (1.1 * 0.9)');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Number.MAX_VALUE is approximately 1.7976931348623157e308
- *
- * @path ch15/15.7/15.7.3/15.7.3.2/S15.7.3.2_A1.js
- * @description Checking Number.MAX_VALUE value
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Number.MAX_VALUE, 1.7976931348623157e308)) {
- $ERROR('#1: Number.MAX_VALUE approximately equal to 1.7976931348623157e308');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Number.MIN_VALUE is approximately 5e-324
- *
- * @path ch15/15.7/15.7.3/15.7.3.3/S15.7.3.3_A1.js
- * @description Checking Number.MIN_VALUE value
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Number.MIN_VALUE, 5e-324)) {
- $ERROR('#1: Number.MIN_VALUE approximately equal to 5e-324');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.E is approximately 2.7182818284590452354
- *
- * @path ch15/15.8/15.8.1/15.8.1.1/S15.8.1.1_A1.js
- * @description Comparing Math.E with 2.7182818284590452354
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Math.E, 2.7182818284590452354)) {
- $ERROR('#1: \'Math.E is not approximately equal to 2.7182818284590452354\'');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.LN10 is approximately 2.302585092994046
- *
- * @path ch15/15.8/15.8.1/15.8.1.2/S15.8.1.2_A1.js
- * @description Comparing Math.LN10 with 2.302585092994046
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Math.LN10, 2.302585092994046)) {
- $ERROR('#1: \'Math.LN10 is not approximately equal to 2.302585092994046\'');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.LN2 is approximately 0.6931471805599453
- *
- * @path ch15/15.8/15.8.1/15.8.1.3/S15.8.1.3_A1.js
- * @description Comparing Math.LN2 with 0.6931471805599453
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Math.LN2, 0.6931471805599453)) {
- $ERROR('#1: \'Math.LN2 is not approximately equal to 0.6931471805599453\'');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.LOG2E is approximately 1.4426950408889634
- *
- * @path ch15/15.8/15.8.1/15.8.1.4/S15.8.1.4_A1.js
- * @description Comparing Math.LOG2E with 1.4426950408889634
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Math.LOG2E, 1.4426950408889634)) {
- $ERROR('#1: \'Math.LOG2E is not approximatley equal to 1.4426950408889634\'');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.LOG10E is approximately 0.4342944819032518
- *
- * @path ch15/15.8/15.8.1/15.8.1.5/S15.8.1.5_A1.js
- * @description Comparing Math.LOG10E with 0.4342944819032518
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Math.LOG10E, 0.4342944819032518)) {
- $ERROR('#1: \'Math.LOG10E is not approximatley equal to 0.4342944819032518\'');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.PI is approximately 3.1415926535897932
- *
- * @path ch15/15.8/15.8.1/15.8.1.6/S15.8.1.6_A1.js
- * @description Comparing Math.PI with 3.1415926535897932
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Math.PI, 3.1415926535897932)) {
- $ERROR('#1: \'Math.PI is not approximatley equal to 3.1415926535897932\'');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.SQRT1_2 is approximately 0.7071067811865476
- *
- * @path ch15/15.8/15.8.1/15.8.1.7/S15.8.1.7_A1.js
- * @description Comparing Math.SQRT1_2 with 0.7071067811865476
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Math.SQRT1_2, 0.7071067811865476)) {
- $ERROR('#1: \'Math.SQRT1_2 is not approximatley equal to 0.7071067811865476\'');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.SQRT2 is approximately 1.4142135623730951
- *
- * @path ch15/15.8/15.8.1/15.8.1.8/S15.8.1.8_A1.js
- * @description Comparing Math.SQRT2 with 1.4142135623730951
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- if (!isEqual(Math.SQRT2, 1.4142135623730951)) {
- $ERROR('#1: \'Math.SQRT2 is not approximatley equal to 1.4142135623730951\'');
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.pow, recommended that implementations use the approximation algorithms for IEEE 754 arithmetic contained in fdlibm
- *
- * @path ch15/15.8/15.8.2/15.8.2.13/S15.8.2.13_A24.js
- * @description Checking if Math.pow(argument1, argument2) is approximately equals to its mathematical value on the set of 64 argument1 values and 64 argument2 values; all the sample values is calculated with LibC
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- vnum = 64;
- var x1 = new Array();
- x1[0] = 0.00000000000000000000;
- x1[1] = 0.25396825396825395000;
- x1[2] = 0.50793650793650791000;
- x1[3] = 0.76190476190476186000;
- x1[4] = 1.01587301587301580000;
- x1[5] = 1.26984126984126980000;
- x1[6] = 1.52380952380952370000;
- x1[7] = 1.77777777777777770000;
- x1[8] = 2.03174603174603160000;
- x1[9] = 2.28571428571428560000;
- x1[10] = 2.53968253968253950000;
- x1[11] = 2.79365079365079350000;
- x1[12] = 3.04761904761904740000;
- x1[13] = 3.30158730158730140000;
- x1[14] = 3.55555555555555540000;
- x1[15] = 3.80952380952380930000;
- x1[16] = 4.06349206349206330000;
- x1[17] = 4.31746031746031720000;
- x1[18] = 4.57142857142857120000;
- x1[19] = 4.82539682539682510000;
- x1[20] = 5.07936507936507910000;
- x1[21] = 5.33333333333333300000;
- x1[22] = 5.58730158730158700000;
- x1[23] = 5.84126984126984090000;
- x1[24] = 6.09523809523809490000;
- x1[25] = 6.34920634920634890000;
- x1[26] = 6.60317460317460280000;
- x1[27] = 6.85714285714285680000;
- x1[28] = 7.11111111111111070000;
- x1[29] = 7.36507936507936470000;
- x1[30] = 7.61904761904761860000;
- x1[31] = 7.87301587301587260000;
- x1[32] = 8.12698412698412650000;
- x1[33] = 8.38095238095238140000;
- x1[34] = 8.63492063492063440000;
- x1[35] = 8.88888888888888930000;
- x1[36] = 9.14285714285714230000;
- x1[37] = 9.39682539682539720000;
- x1[38] = 9.65079365079365030000;
- x1[39] = 9.90476190476190510000;
- x1[40] = 10.15873015873015800000;
- x1[41] = 10.41269841269841300000;
- x1[42] = 10.66666666666666600000;
- x1[43] = 10.92063492063492100000;
- x1[44] = 11.17460317460317400000;
- x1[45] = 11.42857142857142900000;
- x1[46] = 11.68253968253968200000;
- x1[47] = 11.93650793650793700000;
- x1[48] = 12.19047619047619000000;
- x1[49] = 12.44444444444444500000;
- x1[50] = 12.69841269841269800000;
- x1[51] = 12.95238095238095300000;
- x1[52] = 13.20634920634920600000;
- x1[53] = 13.46031746031746000000;
- x1[54] = 13.71428571428571400000;
- x1[55] = 13.96825396825396800000;
- x1[56] = 14.22222222222222100000;
- x1[57] = 14.47619047619047600000;
- x1[58] = 14.73015873015872900000;
- x1[59] = 14.98412698412698400000;
- x1[60] = 15.23809523809523700000;
- x1[61] = 15.49206349206349200000;
- x1[62] = 15.74603174603174500000;
- x1[63] = 16.00000000000000000000;
- var x2 = new Array();
- x2[0] = -16.00000000000000000000;
- x2[1] = -15.49206349206349200000;
- x2[2] = -14.98412698412698400000;
- x2[3] = -14.47619047619047600000;
- x2[4] = -13.96825396825396800000;
- x2[5] = -13.46031746031746000000;
- x2[6] = -12.95238095238095300000;
- x2[7] = -12.44444444444444500000;
- x2[8] = -11.93650793650793700000;
- x2[9] = -11.42857142857142900000;
- x2[10] = -10.92063492063492100000;
- x2[11] = -10.41269841269841300000;
- x2[12] = -9.90476190476190510000;
- x2[13] = -9.39682539682539720000;
- x2[14] = -8.88888888888888930000;
- x2[15] = -8.38095238095238140000;
- x2[16] = -7.87301587301587350000;
- x2[17] = -7.36507936507936560000;
- x2[18] = -6.85714285714285770000;
- x2[19] = -6.34920634920634970000;
- x2[20] = -5.84126984126984180000;
- x2[21] = -5.33333333333333390000;
- x2[22] = -4.82539682539682600000;
- x2[23] = -4.31746031746031810000;
- x2[24] = -3.80952380952381020000;
- x2[25] = -3.30158730158730230000;
- x2[26] = -2.79365079365079440000;
- x2[27] = -2.28571428571428650000;
- x2[28] = -1.77777777777777860000;
- x2[29] = -1.26984126984127070000;
- x2[30] = -0.76190476190476275000;
- x2[31] = -0.25396825396825484000;
- x2[32] = 0.25396825396825307000;
- x2[33] = 0.76190476190476275000;
- x2[34] = 1.26984126984126890000;
- x2[35] = 1.77777777777777860000;
- x2[36] = 2.28571428571428470000;
- x2[37] = 2.79365079365079440000;
- x2[38] = 3.30158730158730050000;
- x2[39] = 3.80952380952381020000;
- x2[40] = 4.31746031746031630000;
- x2[41] = 4.82539682539682600000;
- x2[42] = 5.33333333333333210000;
- x2[43] = 5.84126984126984180000;
- x2[44] = 6.34920634920634800000;
- x2[45] = 6.85714285714285770000;
- x2[46] = 7.36507936507936380000;
- x2[47] = 7.87301587301587350000;
- x2[48] = 8.38095238095237960000;
- x2[49] = 8.88888888888888930000;
- x2[50] = 9.39682539682539540000;
- x2[51] = 9.90476190476190510000;
- x2[52] = 10.41269841269841100000;
- x2[53] = 10.92063492063492100000;
- x2[54] = 11.42857142857142700000;
- x2[55] = 11.93650793650793700000;
- x2[56] = 12.44444444444444300000;
- x2[57] = 12.95238095238095300000;
- x2[58] = 13.46031746031745900000;
- x2[59] = 13.96825396825396800000;
- x2[60] = 14.47619047619047400000;
- x2[61] = 14.98412698412698400000;
- x2[62] = 15.49206349206349000000;
- x2[63] = 16.00000000000000000000;
- var y = new Array();
- y[0] = +Infinity;
- y[1] = 1664158979.11096290000000000000;
- y[2] = 25596.98862206424700000000;
- y[3] = 51.24224360332205900000;
- y[4] = 0.80253721621001273000;
- y[5] = 0.04013281604184240600;
- y[6] = 0.00427181167466968250;
- y[7] = 0.00077698684629307839;
- y[8] = 0.00021140449751288852;
- y[9] = 0.00007886641216275820;
- y[10] = 0.00003797970495625904;
- y[11] = 0.00002260186576944384;
- y[12] = 0.00001608735704675994;
- y[13] = 0.00001335526639440840;
- y[14] = 0.00001267782407825002;
- y[15] = 0.00001354410739307298;
- y[16] = 0.00001607404700077214;
- y[17] = 0.00002096489798949858;
- y[18] = 0.00002978033411316872;
- y[19] = 0.00004572015769326707;
- y[20] = 0.00007536620884896827;
- y[21] = 0.00013263967558882687;
- y[22] = 0.00024800091950917796;
- y[23] = 0.00049049578772052680;
- y[24] = 0.00102225521238885490;
- y[25] = 0.00223744147356661880;
- y[26] = 0.00512739755878587920;
- y[27] = 0.01226918030754863000;
- y[28] = 0.03058049475427409400;
- y[29] = 0.07921771472569966200;
- y[30] = 0.21285098601167457000;
- y[31] = 0.59211846233860321000;
- y[32] = 1.70252376919407730000;
- y[33] = 5.05197994186350920000;
- y[34] = 15.44896866758827700000;
- y[35] = 48.62279949816147700000;
- y[36] = 157.31086033139039000000;
- y[37] = 522.60021277476767000000;
- y[38] = 1780.82316713426990000000;
- y[39] = 6218.58509846337710000000;
- y[40] = 22232.54916898025500000000;
- y[41] = 81310.50695814844200000000;
- y[42] = 303962.39599994919000000000;
- y[43] = 1160609.39151835810000000000;
- y[44] = 4523160.16396183520000000000;
- y[45] = 17980506.53105686600000000000;
- y[46] = 72861260.63140085300000000000;
- y[47] = 300795965.18372804000000000000;
- y[48] = 1264408843.88636260000000000000;
- y[49] = 5408983705.82595920000000000000;
- y[50] = 23536438485.32324600000000000000;
- y[51] = 104125724201.77888000000000000000;
- y[52] = 468137079409.17462000000000000000;
- y[53] = 2137965865913.91260000000000000000;
- y[54] = 9914368643808.25200000000000000000;
- y[55] = 46665726995317.89800000000000000000;
- y[56] = 222863786409039.87000000000000000000;
- y[57] = 1079534443702065.00000000000000000000;
- y[58] = 5302037850329952.00000000000000000000;
- y[59] = 26394813313751084.00000000000000000000;
- y[60] = 133146543235024720.00000000000000000000;
- y[61] = 680375082351885950.00000000000000000000;
- y[62] = 3520878542447823900.00000000000000000000;
- y[63] = 18446744073709552000.00000000000000000000;
- var val;
- for (i = 0; i < vnum; i++)
- {
- val = Math.pow(x1[i], x2[i]);
- if (!isEqual(val, y[i]))
- {
- $ERROR("\nx1 = " + x1[i] + "\nx2 = " + x2[i] + "\nlibc.pow(x1,x2) = " + y[i] + "\nMath.pow(x1,x2) = " + Math.pow(x1[i], x2[i]) + "\nMath.abs(libc.pow(x1,x2) - Math.pow(x1,x2)) > " + prec + "\n\n");
- }
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Sine is a periodic function with period 2*PI
- *
- * @path ch15/15.8/15.8.2/15.8.2.16/S15.8.2.16_A6.js
- * @description Checking if Math.sin(x) equals to Math.sin(x+n*2*Math.PI) with precision 0.000000000003, where n is an integer from 1 to 100 and x is one of 10 float point values from 0 to 2*Math.PI
- */
- // CHECK#1
- prec = 0.000000000003;
- //prec = 0.000000000000001;
- period = 2*Math.PI;
- pernum = 100;
- a = -pernum * period;
- b = pernum * period;
- snum = 9;
- step = period/snum + 0.0;
- x = new Array();
- for (i = 0; i < snum; i++)
- {
- x[i] = a + i*step;
- }
- x[9] = a + period;
- var curval;
- var curx;
- var j;
- for (i = 0; i < snum; i++)
- {
- curval = Math.sin(x[i]);
- curx = x[i] + period;
- j = 0;
- while (curx <= b)
- {
- curx += period;
- j++;
- if (Math.abs(Math.sin(curx) - curval) >= prec)
- {
- $FAIL("#1: sin is found out to not be periodic:\n Math.abs(Math.sin(" + x[i] + ") - Math.sin(" + x[i] + " + 2*Math.PI*" + j + ")) >= " + prec + "\n Math.sin(" + x[i] + ") === " + curval + "\n Math.sin(" + curx + ") === " + Math.sin(curx));
- }
- }
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.sin it is recommended that implementations use the approximation algorithms for IEEE 754 arithmetic contained in fdlibm
- *
- * @path ch15/15.8/15.8.2/15.8.2.16/S15.8.2.16_A7.js
- * @description Checking if Math.sin is approximately equals to its mathematical values on the set of 64 argument values; all the sample values is calculated with LibC
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- vnum = 64;
- var x = new Array();
- x[0] = 0.00000000000000000000;
- x[1] = 0.09973310011396169200;
- x[2] = 0.19946620022792338000;
- x[3] = 0.29919930034188508000;
- x[4] = 0.39893240045584677000;
- x[5] = 0.49866550056980841000;
- x[6] = 0.59839860068377015000;
- x[7] = 0.69813170079773179000;
- x[8] = 0.79786480091169354000;
- x[9] = 0.89759790102565518000;
- x[10] = 0.99733100113961681000;
- x[11] = 1.09706410125357840000;
- x[12] = 1.19679720136754030000;
- x[13] = 1.29653030148150190000;
- x[14] = 1.39626340159546360000;
- x[15] = 1.49599650170942520000;
- x[16] = 1.59572960182338710000;
- x[17] = 1.69546270193734870000;
- x[18] = 1.79519580205131040000;
- x[19] = 1.89492890216527200000;
- x[20] = 1.99466200227923360000;
- x[21] = 2.09439510239319570000;
- x[22] = 2.19412820250715690000;
- x[23] = 2.29386130262111850000;
- x[24] = 2.39359440273508060000;
- x[25] = 2.49332750284904230000;
- x[26] = 2.59306060296300390000;
- x[27] = 2.69279370307696550000;
- x[28] = 2.79252680319092720000;
- x[29] = 2.89225990330488880000;
- x[30] = 2.99199300341885040000;
- x[31] = 3.09172610353281210000;
- x[32] = 3.19145920364677420000;
- x[33] = 3.29119230376073580000;
- x[34] = 3.39092540387469740000;
- x[35] = 3.49065850398865910000;
- x[36] = 3.59039160410262070000;
- x[37] = 3.69012470421658230000;
- x[38] = 3.78985780433054400000;
- x[39] = 3.88959090444450560000;
- x[40] = 3.98932400455846730000;
- x[41] = 4.08905710467242840000;
- x[42] = 4.18879020478639140000;
- x[43] = 4.28852330490035260000;
- x[44] = 4.38825640501431380000;
- x[45] = 4.48798950512827590000;
- x[46] = 4.58772260524223710000;
- x[47] = 4.68745570535619920000;
- x[48] = 4.78718880547016120000;
- x[49] = 4.88692190558412240000;
- x[50] = 4.98665500569808450000;
- x[51] = 5.08638810581204570000;
- x[52] = 5.18612120592600780000;
- x[53] = 5.28585430603996990000;
- x[54] = 5.38558740615393110000;
- x[55] = 5.48532050626789310000;
- x[56] = 5.58505360638185430000;
- x[57] = 5.68478670649581550000;
- x[58] = 5.78451980660977760000;
- x[59] = 5.88425290672373970000;
- x[60] = 5.98398600683770090000;
- x[61] = 6.08371910695166300000;
- x[62] = 6.18345220706562420000;
- x[63] = 6.28318530717958620000;
- var y = new Array();
- y[0] = 0.00000000000000000000;
- y[1] = 0.09956784659581666100;
- y[2] = 0.19814614319939758000;
- y[3] = 0.29475517441090421000;
- y[4] = 0.38843479627469474000;
- y[5] = 0.47825397862131819000;
- y[6] = 0.56332005806362206000;
- y[7] = 0.64278760968653925000;
- y[8] = 0.71586684925971844000;
- y[9] = 0.78183148246802980000;
- y[10] = 0.84002592315077140000;
- y[11] = 0.88987180881146855000;
- y[12] = 0.93087374864420425000;
- y[13] = 0.96262424695001203000;
- y[14] = 0.98480775301220802000;
- y[15] = 0.99720379718118013000;
- y[16] = 0.99968918200081625000;
- y[17] = 0.99223920660017206000;
- y[18] = 0.97492791218182362000;
- y[19] = 0.94792734616713181000;
- y[20] = 0.91150585231167325000;
- y[21] = 0.86602540378443849000;
- y[22] = 0.81193800571585661000;
- y[23] = 0.74978120296773443000;
- y[24] = 0.68017273777091936000;
- y[25] = 0.60380441032547738000;
- y[26] = 0.52143520337949811000;
- y[27] = 0.43388373911755823000;
- y[28] = 0.34202014332566888000;
- y[29] = 0.24675739769029384000;
- y[30] = 0.14904226617617472000;
- y[31] = 0.04984588566069748200;
- y[32] = -0.04984588566069723300;
- y[33] = -0.14904226617617447000;
- y[34] = -0.24675739769029362000;
- y[35] = -0.34202014332566866000;
- y[36] = -0.43388373911755801000;
- y[37] = -0.52143520337949789000;
- y[38] = -0.60380441032547716000;
- y[39] = -0.68017273777091913000;
- y[40] = -0.74978120296773398000;
- y[41] = -0.81193800571585595000;
- y[42] = -0.86602540378443882000;
- y[43] = -0.91150585231167314000;
- y[44] = -0.94792734616713159000;
- y[45] = -0.97492791218182362000;
- y[46] = -0.99223920660017195000;
- y[47] = -0.99968918200081625000;
- y[48] = -0.99720379718118013000;
- y[49] = -0.98480775301220813000;
- y[50] = -0.96262424695001203000;
- y[51] = -0.93087374864420447000;
- y[52] = -0.88987180881146866000;
- y[53] = -0.84002592315077129000;
- y[54] = -0.78183148246802991000;
- y[55] = -0.71586684925971833000;
- y[56] = -0.64278760968653958000;
- y[57] = -0.56332005806362273000;
- y[58] = -0.47825397862131858000;
- y[59] = -0.38843479627469474000;
- y[60] = -0.29475517441090471000;
- y[61] = -0.19814614319939772000;
- y[62] = -0.09956784659581728600;
- y[63] = -0.0000000000000002449293598294706400;
- var val;
- for (i = 0; i < vnum; i++)
- {
- val = Math.sin(x[i]);
- if (!isEqual(val, y[i]))
- {
- $ERROR("\nx = " + x[i] + "\nlibc.sin(x) = " + y[i] + "\nMath.sin(x) = " + Math.sin(x[i]) + "\nMath.abs(libc.sin(x) - Math.sin(x)) > " + prec + "\n\n");
- }
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.sqrt, recommended that implementations use the approximation algorithms for IEEE 754 arithmetic contained in fdlibm
- *
- * @path ch15/15.8/15.8.2/15.8.2.17/S15.8.2.17_A6.js
- * @description Checking if Math.sqrt is approximately equals to its mathematical values on the set of 64 argument values; all the sample values is calculated with LibC
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- vnum = 64;
- var x = new Array();
- x[0] = 0.00000000000000000000;
- x[1] = 0.25396825396825395000;
- x[2] = 0.50793650793650791000;
- x[3] = 0.76190476190476186000;
- x[4] = 1.01587301587301580000;
- x[5] = 1.26984126984126980000;
- x[6] = 1.52380952380952370000;
- x[7] = 1.77777777777777770000;
- x[8] = 2.03174603174603160000;
- x[9] = 2.28571428571428560000;
- x[10] = 2.53968253968253950000;
- x[11] = 2.79365079365079350000;
- x[12] = 3.04761904761904740000;
- x[13] = 3.30158730158730140000;
- x[14] = 3.55555555555555540000;
- x[15] = 3.80952380952380930000;
- x[16] = 4.06349206349206330000;
- x[17] = 4.31746031746031720000;
- x[18] = 4.57142857142857120000;
- x[19] = 4.82539682539682510000;
- x[20] = 5.07936507936507910000;
- x[21] = 5.33333333333333300000;
- x[22] = 5.58730158730158700000;
- x[23] = 5.84126984126984090000;
- x[24] = 6.09523809523809490000;
- x[25] = 6.34920634920634890000;
- x[26] = 6.60317460317460280000;
- x[27] = 6.85714285714285680000;
- x[28] = 7.11111111111111070000;
- x[29] = 7.36507936507936470000;
- x[30] = 7.61904761904761860000;
- x[31] = 7.87301587301587260000;
- x[32] = 8.12698412698412650000;
- x[33] = 8.38095238095238140000;
- x[34] = 8.63492063492063440000;
- x[35] = 8.88888888888888930000;
- x[36] = 9.14285714285714230000;
- x[37] = 9.39682539682539720000;
- x[38] = 9.65079365079365030000;
- x[39] = 9.90476190476190510000;
- x[40] = 10.15873015873015800000;
- x[41] = 10.41269841269841300000;
- x[42] = 10.66666666666666600000;
- x[43] = 10.92063492063492100000;
- x[44] = 11.17460317460317400000;
- x[45] = 11.42857142857142900000;
- x[46] = 11.68253968253968200000;
- x[47] = 11.93650793650793700000;
- x[48] = 12.19047619047619000000;
- x[49] = 12.44444444444444500000;
- x[50] = 12.69841269841269800000;
- x[51] = 12.95238095238095300000;
- x[52] = 13.20634920634920600000;
- x[53] = 13.46031746031746000000;
- x[54] = 13.71428571428571400000;
- x[55] = 13.96825396825396800000;
- x[56] = 14.22222222222222100000;
- x[57] = 14.47619047619047600000;
- x[58] = 14.73015873015872900000;
- x[59] = 14.98412698412698400000;
- x[60] = 15.23809523809523700000;
- x[61] = 15.49206349206349200000;
- x[62] = 15.74603174603174500000;
- x[63] = 16.00000000000000000000;
- var y = new Array();
- y[0] = 0.00000000000000000000;
- y[1] = 0.50395263067896967000;
- y[2] = 0.71269664509979835000;
- y[3] = 0.87287156094396945000;
- y[4] = 1.00790526135793930000;
- y[5] = 1.12687233963802200000;
- y[6] = 1.23442679969673530000;
- y[7] = 1.33333333333333330000;
- y[8] = 1.42539329019959670000;
- y[9] = 1.51185789203690880000;
- y[10] = 1.59363814577919150000;
- y[11] = 1.67142178807468980000;
- y[12] = 1.74574312188793890000;
- y[13] = 1.81702705031799170000;
- y[14] = 1.88561808316412670000;
- y[15] = 1.95180014589706640000;
- y[16] = 2.01581052271587870000;
- y[17] = 2.07784992659727900000;
- y[18] = 2.13808993529939520000;
- y[19] = 2.19667858946110380000;
- y[20] = 2.25374467927604400000;
- y[21] = 2.30940107675850290000;
- y[22] = 2.36374736114111530000;
- y[23] = 2.41687191246657520000;
- y[24] = 2.46885359939347060000;
- y[25] = 2.51976315339484810000;
- y[26] = 2.56966429775848400000;
- y[27] = 2.61861468283190830000;
- y[28] = 2.66666666666666650000;
- y[29] = 2.71386797119523940000;
- y[30] = 2.76026223736941700000;
- y[31] = 2.80588949764880670000;
- y[32] = 2.85078658039919340000;
- y[33] = 2.89498745782298350000;
- y[34] = 2.93852354676981160000;
- y[35] = 2.98142396999971960000;
- y[36] = 3.02371578407381760000;
- y[37] = 3.06542417893925380000;
- y[38] = 3.10657265339049320000;
- y[39] = 3.14718316987777280000;
- y[40] = 3.18727629155838300000;
- y[41] = 3.22687130401855570000;
- y[42] = 3.26598632371090410000;
- y[43] = 3.30463839483761390000;
- y[44] = 3.34284357614937950000;
- y[45] = 3.38061701891406630000;
- y[46] = 3.41797303712883060000;
- y[47] = 3.45492517089848670000;
- y[48] = 3.49148624377587780000;
- y[49] = 3.52766841475278750000;
- y[50] = 3.56348322549899170000;
- y[51] = 3.59894164336974940000;
- y[52] = 3.63405410063598340000;
- y[53] = 3.66883053033489940000;
- y[54] = 3.70328039909020570000;
- y[55] = 3.73741273720925400000;
- y[56] = 3.77123616632825340000;
- y[57] = 3.80475892484536750000;
- y[58] = 3.83798889135426350000;
- y[59] = 3.87093360626696680000;
- y[60] = 3.90360029179413280000;
- y[61] = 3.93599587043272870000;
- y[62] = 3.96812698209517300000;
- y[63] = 4.00000000000000000000;
- var val;
- for (i = 0; i < vnum; i++)
- {
- val = Math.sqrt(x[i]);
- if (!isEqual(val, y[i]))
- {
- $ERROR("\nx = " + x[i] + "\nlibc.sqrt(x) = " + y[i] + "\nMath.sqrt(x) = " + Math.sqrt(x[i]) + "\nMath.abs(libc.sqrt(x) - Math.sqrt(x)) > " + prec + "\n\n");
- }
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Tangent is a periodic function with period PI
- *
- * @path ch15/15.8/15.8.2/15.8.2.18/S15.8.2.18_A6.js
- * @description Checking if Math.tan(x) equals to Math.tan(x+n*Math.PI) with precision 0.000000000003, where n is an integer from 1 to 100 and x is one of 10 float point values from 0 to Math.PI
- */
- // CHECK#1
- prec = 0.00000000003;
- //prec = 0.000000000000001;
- period = Math.PI;
- pernum = 100;
- a = -pernum * period + period/2;
- b = pernum * period - period/2;
- snum = 9;
- step = period/(snum + 2);
- x = new Array();
- for (i = 0; i <= snum; i++) //// We exlude special points
- { //// in this cycle.
- x[i] = a + (i+1)*step; ////
- } ////
- var curval;
- var curx;
- var j;
- for (i = 0; i < snum; i++)
- {
- curval = Math.tan(x[i]);
- curx = x[i] + period;
- j = 0;
- while (curx <= b)
- {
- curx += period;
- j++;
- if (Math.abs(Math.tan(curx) - curval) >= prec)
- {
- $FAIL("#1: tan is found out to not be periodic:\n Math.abs(Math.tan(" + x[i] + ") - Math.tan(" + x[i] + " + 2*Math.PI*" + j + ")) >= " + prec + "\n Math.tan(" + x[i] + ") === " + curval + "\n Math.tan(" + curx + ") === " + Math.tan(curx));
- }
- }
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If x is +Infinity, Math.atan(x) is an implementation-dependent approximation to +PI/2
- *
- * @path ch15/15.8/15.8.2/15.8.2.4/S15.8.2.4_A4.js
- * @description Checking if Math.atan(+Infinity) is an approximation to +PI/2
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- var x = +Infinity;
- if (!isEqual(Math.atan(x),Math.PI/2))
- {
- $ERROR("#1: '!isEqual(Math.atan(+Infinity), Math.PI/2)'");
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If x is -Infinity, Math.atan(x) is an implementation-dependent approximation to -PI/2
- *
- * @path ch15/15.8/15.8.2/15.8.2.4/S15.8.2.4_A5.js
- * @description Checking if Math.atan(-Infinity) is an approximation to -PI/2
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- var x = -Infinity;
- if (!isEqual(Math.atan(x), -Math.PI/2))
- {
- $ERROR("#1: '!isEqual(Math.atan(-Infinity), -Math.PI/2)'");
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y is -0 and x is -0, Math.atan2(y,x) is an implementation-dependent approximation to -PI
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A10.js
- * @description Checking if Math.atan2(-0,-0) is an approximation to -PI
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- //prec = 0.00000000000001;
- y = -0;
- x = -0;
- if (!isEqual(Math.atan2(y,x), -Math.PI))
- $ERROR("#1: !isEqual(Math.atan2(-0,-0), -Math.PI)");
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y is equal to -0 and x<0, Math.atan2(y,x) is an implementation-dependent approximation to -PI
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A11.js
- * @description Checking if Math.atan2(-0,x) is an approximation to -PI, where x<0
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- y = -0;
- //prec = 0.00000000000001;
- x = new Array();
- x[0] = -0.000000000000001;
- x[2] = -Infinity;
- x[1] = -1;
- xnum = 3;
- for (i = 0; i < xnum; i++)
- {
- if (!isEqual(Math.atan2(y,x[i]), - Math.PI))
- $FAIL("#1: Math.abs(Math.atan2(" + y + ", " + x[i] + ") + Math.PI) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y<0 and x is +0, Math.atan2(y,x) is an implementation-dependent approximation to -PI/2
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A12.js
- * @description Checking if Math.atan2(y,+0) is an approximation to -PI/2, where y<0
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- x = +0;
- //prec = 0.00000000000001;
- y = new Array();
- y[0] = -0.000000000000001;
- y[2] = -Infinity;
- y[1] = -1;
- ynum = 3;
- for (i = 0; i < ynum; i++)
- {
- if (!isEqual(Math.atan2(y[i],x), -(Math.PI)/2))
- $FAIL("#1: Math.abs(Math.atan2(" + y[i] + ", " + x + ") + ((Math.PI)/2)) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y<0 and x is -0, Math.atan2(y,x) is an implementation-dependent approximation to -PI/2
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A13.js
- * @description Checking if Math.atan2(y,-0) is an approximation to -PI/2, where y<0
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- x = -0;
- //prec = 0.00000000000001;
- y = new Array();
- y[0] = -0.000000000000001;
- y[2] = -Infinity;
- y[1] = -1;
- ynum = 3;
- for (i = 0; i < ynum; i++)
- {
- if (!isEqual(Math.atan2(y[i],x), -(Math.PI)/2))
- $FAIL("#1: Math.abs(Math.atan2(" + y[i] + ", -0) + ((Math.PI)/2)) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y>0 and y is finite and x is equal to -Infinity, Math.atan2(y,x) is an implementation-dependent approximation to +PI
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A15.js
- * @description Checking if Math.atan2(y,x) is an approximation to +PI, where y>0 and y is finite and x is equal to -Infinity
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- x = -Infinity;
- y = new Array();
- y[0] = 0.000000000000001;
- y[1] = 1;
- y[2] = 1.7976931348623157E308; //largest finite number
- ynum = 3;
- for (i = 0; i < ynum; i++)
- {
- if (!isEqual(Math.atan2(y[i],x),Math.PI))
- $FAIL("#1: Math.abs(Math.atan2(" + y[i] + ", " + x + ") - Math.PI) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y<0 and y is finite and x is equal to -Infinity, Math.atan2(y,x) is an implementation-dependent approximation to -PI
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A17.js
- * @description Checking if Math.atan2(y,x) is an approximation to -PI, where y<0 and y is finite and x is equal to -Infinity
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- x = -Infinity;
- y = new Array();
- y[0] = -0.000000000000001;
- y[1] = -1;
- y[2] = -1.7976931348623157E308; //largest (by module) finite number
- ynum = 3;
- for (i = 0; i < ynum; i++)
- {
- if (!isEqual(Math.atan2(y[i],x), -Math.PI))
- $FAIL("#1: Math.abs(Math.atan2(" + y[i] + ", " + x + ") + Math.PI) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y is +Infinity and x is finite, Math.atan2(y,x) is an implementation-dependent approximation to +PI/2
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A18.js
- * @description Checking if Math.atan2(y,x) is an approximation to +PI/2, where y is +Infinity and x is finite
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- y = +Infinity;
- x = new Array();
- x[0] = 0.000000000000001;
- x[1] = 1;
- x[2] = 1.7976931348623157E308; //largest finite number
- x[3] = -0.000000000000001;
- x[4] = -1;
- x[5] = -1.7976931348623157E308; //largest (by module) finite number
- xnum = 6;
- for (i = 0; i < xnum; i++)
- {
- if (!isEqual(Math.atan2(y,x[i]), (Math.PI)/2))
- $FAIL("#1: Math.abs(Math.atan2(" + y + ", " + x[i] + ") - (Math.PI/2)) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y is -Infinity and x is finite, Math.atan2(y,x) is an implementation-dependent approximation to -PI/2
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A19.js
- * @description Checking if Math.atan2(y,x) is an approximation to -PI/2, where y is -Infinity and x is finite
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- //prec = 0.00000000000001;
- y = -Infinity;
- x = new Array();
- x[0] = 0.000000000000001;
- x[1] = 1;
- x[2] = 1.7976931348623157E308; //largest finite number
- x[3] = -0.000000000000001;
- x[4] = -1;
- x[5] = -1.7976931348623157E308; //largest (by module) finite number
- xnum = 6;
- for (i = 0; i < xnum; i++)
- {
- if (!isEqual(Math.atan2(y,x[i]), -(Math.PI)/2))
- $FAIL("#1: Math.abs(Math.atan2(" + y + ", " + x[i] + ") + (Math.PI/2)) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y>0 and x is +0, Math.atan2(y,x) is an implementation-dependent approximation to +PI/2
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A2.js
- * @description Checking if Math.atan2(y,x) is an approximation to +PI/2, where y>0 and x is +0
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- x = +0;
- //prec = 0.00000000000001;
- y = new Array();
- y[0] = 0.000000000000001;
- y[2] = +Infinity;
- y[1] = 1;
- ynum = 3;
- for (i = 0; i < ynum; i++)
- {
- if (!isEqual(Math.atan2(y[i],x),(Math.PI)/2))
- $FAIL("#1: Math.abs(Math.atan2(" + y[i] + ", " + x + ") - ((Math.PI)/2)) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y is equal to +Infinity and x is equal to -Infinity, Math.atan2(y,x) is an implementation-dependent approximation to +3*PI/4
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A21.js
- * @description Checking if Math.atan2(y,x) is an approximation to +3*PI/4, where y is equal to +Infinity and x is equal to -Infinity
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- //prec = 0.00000000000001;
- y = +Infinity;
- x = -Infinity;
- if (!isEqual(Math.atan2(y,x), (3*Math.PI)/4))
- $ERROR("#1: Math.abs(Math.atan2(" + y + ", " + x + ") - (3*Math.PI/4)) >= " + prec);
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y is equal to -Infinity and x is equal to -Infinity, Math.atan2(y,x) is an implementation-dependent approximation to -3*PI/4
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A23.js
- * @description Checking if Math.atan2(y,x) is an approximation to -3*PI/4, where y is equal to -Infinity and x is equal to -Infinity
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- //prec = 0.00000000000001;
- y = -Infinity;
- x = -Infinity;
- if (!isEqual(Math.atan2(y,x), -(3*Math.PI)/4))
- $ERROR("#1: Math.abs(Math.atan2(" + y + ", " + x + ") + (3*Math.PI/4)) >= " + prec);
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.atan2, recommended that implementations use the approximation algorithms for IEEE 754 arithmetic contained in fdlibm
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A24.js
- * @description Checking if Math.atan2(argument1, argument2) is approximately equals to its mathematical values on the set of 64 argument1 values and 64 argument2 values; all the sample values is calculated with LibC
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- vnum = 64;
- var x1 = new Array();
- x1[0] = -16.00000000000000000000;
- x1[1] = -15.49206349206349200000;
- x1[2] = -14.98412698412698400000;
- x1[3] = -14.47619047619047600000;
- x1[4] = -13.96825396825396800000;
- x1[5] = -13.46031746031746000000;
- x1[6] = -12.95238095238095300000;
- x1[7] = -12.44444444444444500000;
- x1[8] = -11.93650793650793700000;
- x1[9] = -11.42857142857142900000;
- x1[10] = -10.92063492063492100000;
- x1[11] = -10.41269841269841300000;
- x1[12] = -9.90476190476190510000;
- x1[13] = -9.39682539682539720000;
- x1[14] = -8.88888888888888930000;
- x1[15] = -8.38095238095238140000;
- x1[16] = -7.87301587301587350000;
- x1[17] = -7.36507936507936560000;
- x1[18] = -6.85714285714285770000;
- x1[19] = -6.34920634920634970000;
- x1[20] = -5.84126984126984180000;
- x1[21] = -5.33333333333333390000;
- x1[22] = -4.82539682539682600000;
- x1[23] = -4.31746031746031810000;
- x1[24] = -3.80952380952381020000;
- x1[25] = -3.30158730158730230000;
- x1[26] = -2.79365079365079440000;
- x1[27] = -2.28571428571428650000;
- x1[28] = -1.77777777777777860000;
- x1[29] = -1.26984126984127070000;
- x1[30] = -0.76190476190476275000;
- x1[31] = -0.25396825396825484000;
- x1[32] = 0.25396825396825307000;
- x1[33] = 0.76190476190476275000;
- x1[34] = 1.26984126984126890000;
- x1[35] = 1.77777777777777860000;
- x1[36] = 2.28571428571428470000;
- x1[37] = 2.79365079365079440000;
- x1[38] = 3.30158730158730050000;
- x1[39] = 3.80952380952381020000;
- x1[40] = 4.31746031746031630000;
- x1[41] = 4.82539682539682600000;
- x1[42] = 5.33333333333333210000;
- x1[43] = 5.84126984126984180000;
- x1[44] = 6.34920634920634800000;
- x1[45] = 6.85714285714285770000;
- x1[46] = 7.36507936507936380000;
- x1[47] = 7.87301587301587350000;
- x1[48] = 8.38095238095237960000;
- x1[49] = 8.88888888888888930000;
- x1[50] = 9.39682539682539540000;
- x1[51] = 9.90476190476190510000;
- x1[52] = 10.41269841269841100000;
- x1[53] = 10.92063492063492100000;
- x1[54] = 11.42857142857142700000;
- x1[55] = 11.93650793650793700000;
- x1[56] = 12.44444444444444300000;
- x1[57] = 12.95238095238095300000;
- x1[58] = 13.46031746031745900000;
- x1[59] = 13.96825396825396800000;
- x1[60] = 14.47619047619047400000;
- x1[61] = 14.98412698412698400000;
- x1[62] = 15.49206349206349000000;
- x1[63] = 16.00000000000000000000;
- var x2 = new Array();
- x2[0] = -8.00000000000000000000;
- x2[1] = -7.74603174603174600000;
- x2[2] = -7.49206349206349210000;
- x2[3] = -7.23809523809523810000;
- x2[4] = -6.98412698412698420000;
- x2[5] = -6.73015873015873020000;
- x2[6] = -6.47619047619047630000;
- x2[7] = -6.22222222222222230000;
- x2[8] = -5.96825396825396840000;
- x2[9] = -5.71428571428571440000;
- x2[10] = -5.46031746031746050000;
- x2[11] = -5.20634920634920650000;
- x2[12] = -4.95238095238095260000;
- x2[13] = -4.69841269841269860000;
- x2[14] = -4.44444444444444460000;
- x2[15] = -4.19047619047619070000;
- x2[16] = -3.93650793650793670000;
- x2[17] = -3.68253968253968280000;
- x2[18] = -3.42857142857142880000;
- x2[19] = -3.17460317460317490000;
- x2[20] = -2.92063492063492090000;
- x2[21] = -2.66666666666666700000;
- x2[22] = -2.41269841269841300000;
- x2[23] = -2.15873015873015910000;
- x2[24] = -1.90476190476190510000;
- x2[25] = -1.65079365079365110000;
- x2[26] = -1.39682539682539720000;
- x2[27] = -1.14285714285714320000;
- x2[28] = -0.88888888888888928000;
- x2[29] = -0.63492063492063533000;
- x2[30] = -0.38095238095238138000;
- x2[31] = -0.12698412698412742000;
- x2[32] = 0.12698412698412653000;
- x2[33] = 0.38095238095238138000;
- x2[34] = 0.63492063492063444000;
- x2[35] = 0.88888888888888928000;
- x2[36] = 1.14285714285714230000;
- x2[37] = 1.39682539682539720000;
- x2[38] = 1.65079365079365030000;
- x2[39] = 1.90476190476190510000;
- x2[40] = 2.15873015873015820000;
- x2[41] = 2.41269841269841300000;
- x2[42] = 2.66666666666666610000;
- x2[43] = 2.92063492063492090000;
- x2[44] = 3.17460317460317400000;
- x2[45] = 3.42857142857142880000;
- x2[46] = 3.68253968253968190000;
- x2[47] = 3.93650793650793670000;
- x2[48] = 4.19047619047618980000;
- x2[49] = 4.44444444444444460000;
- x2[50] = 4.69841269841269770000;
- x2[51] = 4.95238095238095260000;
- x2[52] = 5.20634920634920560000;
- x2[53] = 5.46031746031746050000;
- x2[54] = 5.71428571428571350000;
- x2[55] = 5.96825396825396840000;
- x2[56] = 6.22222222222222140000;
- x2[57] = 6.47619047619047630000;
- x2[58] = 6.73015873015872930000;
- x2[59] = 6.98412698412698420000;
- x2[60] = 7.23809523809523720000;
- x2[61] = 7.49206349206349210000;
- x2[62] = 7.74603174603174520000;
- x2[63] = 8.00000000000000000000;
- var y = new Array();
- y[0] = -2.03444393579570270000;
- y[1] = -2.03444393579570270000;
- y[2] = -2.03444393579570270000;
- y[3] = -2.03444393579570270000;
- y[4] = -2.03444393579570270000;
- y[5] = -2.03444393579570270000;
- y[6] = -2.03444393579570270000;
- y[7] = -2.03444393579570270000;
- y[8] = -2.03444393579570270000;
- y[9] = -2.03444393579570270000;
- y[10] = -2.03444393579570270000;
- y[11] = -2.03444393579570270000;
- y[12] = -2.03444393579570270000;
- y[13] = -2.03444393579570270000;
- y[14] = -2.03444393579570270000;
- y[15] = -2.03444393579570270000;
- y[16] = -2.03444393579570270000;
- y[17] = -2.03444393579570270000;
- y[18] = -2.03444393579570270000;
- y[19] = -2.03444393579570270000;
- y[20] = -2.03444393579570270000;
- y[21] = -2.03444393579570270000;
- y[22] = -2.03444393579570270000;
- y[23] = -2.03444393579570270000;
- y[24] = -2.03444393579570270000;
- y[25] = -2.03444393579570270000;
- y[26] = -2.03444393579570270000;
- y[27] = -2.03444393579570270000;
- y[28] = -2.03444393579570270000;
- y[29] = -2.03444393579570270000;
- y[30] = -2.03444393579570270000;
- y[31] = -2.03444393579570270000;
- y[32] = 1.10714871779409040000;
- y[33] = 1.10714871779409040000;
- y[34] = 1.10714871779409040000;
- y[35] = 1.10714871779409040000;
- y[36] = 1.10714871779409040000;
- y[37] = 1.10714871779409040000;
- y[38] = 1.10714871779409040000;
- y[39] = 1.10714871779409040000;
- y[40] = 1.10714871779409040000;
- y[41] = 1.10714871779409040000;
- y[42] = 1.10714871779409040000;
- y[43] = 1.10714871779409040000;
- y[44] = 1.10714871779409040000;
- y[45] = 1.10714871779409040000;
- y[46] = 1.10714871779409040000;
- y[47] = 1.10714871779409040000;
- y[48] = 1.10714871779409040000;
- y[49] = 1.10714871779409040000;
- y[50] = 1.10714871779409040000;
- y[51] = 1.10714871779409040000;
- y[52] = 1.10714871779409040000;
- y[53] = 1.10714871779409040000;
- y[54] = 1.10714871779409040000;
- y[55] = 1.10714871779409040000;
- y[56] = 1.10714871779409040000;
- y[57] = 1.10714871779409040000;
- y[58] = 1.10714871779409040000;
- y[59] = 1.10714871779409040000;
- y[60] = 1.10714871779409040000;
- y[61] = 1.10714871779409040000;
- y[62] = 1.10714871779409040000;
- y[63] = 1.10714871779409040000;
- var val;
- for (i = 0; i < vnum; i++)
- {
- val = Math.atan2(x1[i], x2[i]);
- if (!isEqual(val, y[i]))
- {
- $ERROR("\nx1 = " + x1[i] + "\nx2 = " + x2[i] + "\nlibc.atan2(x1,x2) = " + y[i] + "\nMath.atan2(x1,x2) = " + Math.atan2(x1[i],x2[i]) + "\nMath.abs(libc.atan2(x1,x2) - Math.atan2(x1,x2)) > " + prec + "\n\n");
- }
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y>0 and x is -0, Math.atan2(y,x) is an implementation-dependent approximation to +PI/2
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A3.js
- * @description Checking if Math.atan2(y,x) is an approximation to +PI/2, where y>0 and x is -0
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- x = -0;
- //prec = 0.00000000000001;
- y = new Array();
- y[0] = 0.000000000000001;
- y[2] = +Infinity;
- y[1] = 1;
- ynum = 3;
- for (i = 0; i < ynum; i++)
- {
- if (!isEqual(Math.atan2(y[i],x), (Math.PI)/2))
- $FAIL("#1: Math.abs(Math.atan2(" + y[i] + ", " + x + ") - ((Math.PI)/2)) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y is +0 and x is -0, Math.atan2(y,x) is an implementation-dependent approximation to +PI
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A6.js
- * @description Checking if Math.atan2(y,x) is an approximation to +PI, where y is +0 and x is -0
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- //prec = 0.00000000000001;
- y = +0;
- x = -0;
- if (!isEqual(Math.atan2(y,x), Math.PI))
- $ERROR("#1: Math.abs(Math.atan2(" + y + ", -0) - Math.PI) >= " + prec);
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * If y is equal to +0 and x<0, Math.atan2(y,x) is an implementation-dependent approximation to +PI
- *
- * @path ch15/15.8/15.8.2/15.8.2.5/S15.8.2.5_A7.js
- * @description Checking if Math.atan2(y,x) is an approximation to +PI, where y is equal to +0 and x<0
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- y = +0;
- //prec = 0.00000000000001;
- x = new Array();
- x[0] = -0.000000000000001;
- x[2] = -Infinity;
- x[1] = -1;
- xnum = 3;
- for (i = 0; i < xnum; i++)
- {
- if (!isEqual(Math.atan2(y,x[i]), Math.PI))
- $FAIL("#1: Math.abs(Math.atan2(" + y + ", " + x[i] + ") - Math.PI) >= " + prec);
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Cosine is a periodic function with period 2*PI
- *
- * @path ch15/15.8/15.8.2/15.8.2.7/S15.8.2.7_A6.js
- * @description Checking if Math.cos(x) equals to Math.cos(x+n*2*Math.PI) with precision 0.000000000003, where n is an integer from 1 to 100 and x is one of 10 float point values from -Math.PI to +Math.PI
- */
- // CHECK#1
- prec = 0.000000000003;
- //prec = 0.000000000000001;
- period = 2*Math.PI;
- pernum = 100;
- a = -pernum * period;
- b = pernum * period;
- snum = 9;
- step = period/snum + 0.0;
- x = new Array();
- for (i = 0; i < snum; i++)
- {
- x[i] = a + i*step;
- }
- x[9] = a + period;
- var curval;
- var curx;
- var j;
- for (i = 0; i < snum; i++)
- {
- curval = Math.cos(x[i]);
- curx = x[i] + period;
- j = 0;
- while (curx <= b)
- {
- curx += period;
- j++;
- if (Math.abs(Math.cos(curx) - curval) >= prec)
- {
- $FAIL("#1: cos is found out to not be periodic:\n Math.abs(Math.cos(" + x[i] + ") - Math.cos(" + x[i] + " + 2*Math.PI*" + j + ")) >= " + prec + "\n Math.cos(" + x[i] + ") === " + curval + "\n Math.cos(" + curx + ") === " + Math.cos(curx));
- }
- }
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Math.cos it is recommended that implementations use the approximation algorithms for IEEE 754 arithmetic contained in fdlibm
- *
- * @path ch15/15.8/15.8.2/15.8.2.7/S15.8.2.7_A7.js
- * @description Checking if Math.cos is approximately equals to its mathematical values on the set of 64 argument values; all the sample values is calculated with LibC
- */
- $INCLUDE("math_precision.js");
- $INCLUDE("math_isequal.js");
- // CHECK#1
- vnum = 64;
- var x = new Array();
- x[0] = -3.14159265358979310000;
- x[1] = -3.04185955347583150000;
- x[2] = -2.94212645336186980000;
- x[3] = -2.84239335324790820000;
- x[4] = -2.74266025313394660000;
- x[5] = -2.64292715301998450000;
- x[6] = -2.54319405290602290000;
- x[7] = -2.44346095279206120000;
- x[8] = -2.34372785267809960000;
- x[9] = -2.24399475256413790000;
- x[10] = -2.14426165245017630000;
- x[11] = -2.04452855233621470000;
- x[12] = -1.94479545222225280000;
- x[13] = -1.84506235210829120000;
- x[14] = -1.74532925199432950000;
- x[15] = -1.64559615188036790000;
- x[16] = -1.54586305176640600000;
- x[17] = -1.44612995165244440000;
- x[18] = -1.34639685153848280000;
- x[19] = -1.24666375142452110000;
- x[20] = -1.14693065131055950000;
- x[21] = -1.04719755119659740000;
- x[22] = -0.94746445108263622000;
- x[23] = -0.84773135096867458000;
- x[24] = -0.74799825085471250000;
- x[25] = -0.64826515074075086000;
- x[26] = -0.54853205062678922000;
- x[27] = -0.44879895051282759000;
- x[28] = -0.34906585039886595000;
- x[29] = -0.24933275028490431000;
- x[30] = -0.14959965017094268000;
- x[31] = -0.04986655005698104000;
- x[32] = 0.04986655005698104000;
- x[33] = 0.14959965017094268000;
- x[34] = 0.24933275028490431000;
- x[35] = 0.34906585039886595000;
- x[36] = 0.44879895051282759000;
- x[37] = 0.54853205062678922000;
- x[38] = 0.64826515074075086000;
- x[39] = 0.74799825085471250000;
- x[40] = 0.84773135096867414000;
- x[41] = 0.94746445108263533000;
- x[42] = 1.04719755119659830000;
- x[43] = 1.14693065131055950000;
- x[44] = 1.24666375142452070000;
- x[45] = 1.34639685153848280000;
- x[46] = 1.44612995165244400000;
- x[47] = 1.54586305176640600000;
- x[48] = 1.64559615188036810000;
- x[49] = 1.74532925199432930000;
- x[50] = 1.84506235210829140000;
- x[51] = 1.94479545222225260000;
- x[52] = 2.04452855233621470000;
- x[53] = 2.14426165245017670000;
- x[54] = 2.24399475256413790000;
- x[55] = 2.34372785267810000000;
- x[56] = 2.44346095279206120000;
- x[57] = 2.54319405290602240000;
- x[58] = 2.64292715301998450000;
- x[59] = 2.74266025313394660000;
- x[60] = 2.84239335324790780000;
- x[61] = 2.94212645336186980000;
- x[62] = 3.04185955347583100000;
- x[63] = 3.14159265358979310000;
- var y = new Array();
- y[0] = -1.00000000000000000000;
- y[1] = -0.99503077536540141000;
- y[2] = -0.98017248784854383000;
- y[3] = -0.95557280578614079000;
- y[4] = -0.92147621187040774000;
- y[5] = -0.87822157337022844000;
- y[6] = -0.82623877431599468000;
- y[7] = -0.76604444311897790000;
- y[8] = -0.69823681808607274000;
- y[9] = -0.62348980185873348000;
- y[10] = -0.54254626386575933000;
- y[11] = -0.45621065735316296000;
- y[12] = -0.36534102436639487000;
- y[13] = -0.27084046814300500000;
- y[14] = -0.17364817766693030000;
- y[15] = -0.07473009358642426800;
- y[16] = 0.02493069173807303500;
- y[17] = 0.12434370464748527000;
- y[18] = 0.22252093395631445000;
- y[19] = 0.31848665025168443000;
- y[20] = 0.41128710313061151000;
- y[21] = 0.50000000000000033000;
- y[22] = 0.58374367223478973000;
- y[23] = 0.66168583759685928000;
- y[24] = 0.73305187182982645000;
- y[25] = 0.79713250722292250000;
- y[26] = 0.85329088163215572000;
- y[27] = 0.90096886790241915000;
- y[28] = 0.93969262078590832000;
- y[29] = 0.96907728622907796000;
- y[30] = 0.98883082622512852000;
- y[31] = 0.99875692121892234000;
- y[32] = 0.99875692121892234000;
- y[33] = 0.98883082622512852000;
- y[34] = 0.96907728622907796000;
- y[35] = 0.93969262078590832000;
- y[36] = 0.90096886790241915000;
- y[37] = 0.85329088163215572000;
- y[38] = 0.79713250722292250000;
- y[39] = 0.73305187182982645000;
- y[40] = 0.66168583759685962000;
- y[41] = 0.58374367223479051000;
- y[42] = 0.49999999999999950000;
- y[43] = 0.41128710313061151000;
- y[44] = 0.31848665025168482000;
- y[45] = 0.22252093395631445000;
- y[46] = 0.12434370464748572000;
- y[47] = 0.02493069173807303500;
- y[48] = -0.07473009358642449000;
- y[49] = -0.17364817766693008000;
- y[50] = -0.27084046814300522000;
- y[51] = -0.36534102436639465000;
- y[52] = -0.45621065735316296000;
- y[53] = -0.54254626386575977000;
- y[54] = -0.62348980185873348000;
- y[55] = -0.69823681808607307000;
- y[56] = -0.76604444311897790000;
- y[57] = -0.82623877431599446000;
- y[58] = -0.87822157337022844000;
- y[59] = -0.92147621187040774000;
- y[60] = -0.95557280578614057000;
- y[61] = -0.98017248784854383000;
- y[62] = -0.99503077536540141000;
- y[63] = -1.00000000000000000000;
- var val;
- for (i = 0; i < vnum; i++)
- {
- val = Math.cos(x[i]);
- if (!isEqual(val, y[i]))
- {
- $ERROR("\nx = " + x[i] + "\nlibc.cos(x) = " + y[i] + "\nMath.cos(x) = " + Math.cos(x[i]) + "\nMath.abs(libc.cos(x) - Math.cos(x)) > " + prec + "\n\n");
- }
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Number type represented as the double precision 64-bit format IEEE 754
- *
- * @path ch08/8.5/S8.5_A2.1.js
- * @description Use 2^53 + 2 number and do some operation with it
- */
- var x = 9007199254740994.0; /* 2^53 + 2 */
- var y = 1.0 - 1/65536.0;
- var z = x + y;
- var d = z - x;
- if (d !== 0){
- $ERROR('#1: var x = 9007199254740994.0; var y = 1.0 - 1/65536.0; var z = x + y; var d = z - x; d === 0. Actual: ' + (d));
- }
- // Copyright 2009 the Sputnik authors. All rights reserved.
- // This code is governed by the BSD license found in the LICENSE file.
- /**
- * Number type represented as the extended precision 64-bit format IEEE 754
- *
- * @path ch08/8.5/S8.5_A2.2.js
- * @description Use 2^53 + 2 number and do some operation with it
- */
- var x = 9007199254740994.0; /* 2^53 + 2 */
- var y = 1.0 - 1/65536.0;
- var z = x + y;
- var d = z - x;
- if (d === 2){
- $ERROR('#1: var x = 9007199254740994.0; var y = 1.0 - 1/65536.0; var z = x + y; var d = z - x; d !== 2');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement