S11.6.1_A4_T7.js (1595B)
1 // Copyright 2009 the Sputnik authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 info: | 6 The result of an addition is determined using the rules of IEEE 754 7 double-precision arithmetics 8 es5id: 11.6.1_A4_T7 9 description: > 10 The sum of two nonzero finite values of the same magnitude and 11 opposite sign is +0 12 ---*/ 13 14 //CHECK#1 15 if (-Number.MIN_VALUE + Number.MIN_VALUE !== +0) { 16 throw new Test262Error('#1.1: -Number.MIN_VALUE + Number.MIN_VALUE === 0. Actual: ' + (-Number.MIN_VALUE + Number.MIN_VALUE)); 17 } else { 18 if (1 / (-Number.MIN_VALUE + Number.MIN_VALUE) !== Number.POSITIVE_INFINITY) { 19 throw new Test262Error('#1.2: -Number.MIN_VALUE + Number.MIN_VALUE === + 0. Actual: -0'); 20 } 21 } 22 23 //CHECK#2 24 if (-Number.MAX_VALUE + Number.MAX_VALUE !== +0) { 25 throw new Test262Error('#2.1: -Number.MAX_VALUE + Number.MAX_VALUE === 0. Actual: ' + (-Number.MAX_VALUE + Number.MAX_VALUE)); 26 } else { 27 if (1 / (-Number.MAX_VALUE + Number.MAX_VALUE) !== Number.POSITIVE_INFINITY) { 28 throw new Test262Error('#2.2: -Number.MAX_VALUE + Number.MAX_VALUE === + 0. Actual: -0'); 29 } 30 } 31 32 //CHECK#3 33 if (-1 / Number.MAX_VALUE + 1 / Number.MAX_VALUE !== +0) { 34 throw new Test262Error('#3.1: -1 / Number.MAX_VALUE + 1 / Number.MAX_VALUE === 0. Actual: ' + (-1 / Number.MAX_VALUE + 1 / Number.MAX_VALUE)); 35 } else { 36 if (1 / (-1 / Number.MAX_VALUE + 1 / Number.MAX_VALUE) !== Number.POSITIVE_INFINITY) { 37 throw new Test262Error('#3.2: -1 / Number.MAX_VALUE + 1 / Number.MAX_VALUE === + 0. Actual: -0'); 38 } 39 } 40 41 reportCompare(0, 0);