| 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_T5 |
| 9 |
description: > |
| 10 |
The sum of two negative zeros is -0. The sum of two positive |
| 11 |
zeros, or of two zeros of opposite sign is +0 |
| 12 |
---*/ |
| 13 |
|
| 14 |
//CHECK#1 |
| 15 |
if (-0 + -0 !== -0 ) { |
| 16 |
$ERROR('#1.1: -0 + -0 === 0. Actual: ' + (-0 + -0)); |
| 17 |
} else { |
| 18 |
if (1 / (-0 + -0) !== Number.NEGATIVE_INFINITY) { |
| 19 |
$ERROR('#1.1: -0 + -0 === - 0. Actual: +0'); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
//CHECK#2 |
| 24 |
if (0 + -0 !== 0 ) { |
| 25 |
$ERROR('#2.1: 0 + -0 === 0. Actual: ' + (0 + -0)); |
| 26 |
} else { |
| 27 |
if (1 / (0 + -0) !== Number.POSITIVE_INFINITY) { |
| 28 |
$ERROR('#2.2: 0 + -0 === + 0. Actual: -0'); |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
//CHECK#3 |
| 33 |
if (-0 + 0 !== 0 ) { |
| 34 |
$ERROR('#3.1: -0 + 0 === 0. Actual: ' + (-0 + 0)); |
| 35 |
} else { |
| 36 |
if (1 / (-0 + 0) !== Number.POSITIVE_INFINITY) { |
| 37 |
$ERROR('#3.2: -0 + 0 === + 0. Actual: -0'); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
//CHECK#4 |
| 42 |
if (0 + 0 !== 0 ) { |
| 43 |
$ERROR('#4.1: 0 + 0 === 0. Actual: ' + (0 + 0)); |
| 44 |
} else { |
| 45 |
if (1 / (0 + 0) !== Number.POSITIVE_INFINITY) { |
| 46 |
$ERROR('#4.2: 0 + 0 === + 0. Actual: -0'); |
| 47 |
} |
| 48 |
} |