|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 File Name: 11.5.1.js |
|
9 ECMA Section: 11.5.1 Applying the * operator |
|
10 Description: |
|
11 |
|
12 11.5.1 Applying the * operator |
|
13 |
|
14 The * operator performs multiplication, producing the product of its |
|
15 operands. Multiplication is commutative. Multiplication is not always |
|
16 associative in ECMAScript, because of finite precision. |
|
17 |
|
18 The result of a floating-point multiplication is governed by the rules |
|
19 of IEEE 754 double-precision arithmetic: |
|
20 |
|
21 If either operand is NaN, the result is NaN. |
|
22 The sign of the result is positive if both operands have the same sign, |
|
23 negative if the operands have different signs. |
|
24 Multiplication of an infinity by a zero results in NaN. |
|
25 Multiplication of an infinity by an infinity results in an infinity. |
|
26 The sign is determined by the rule already stated above. |
|
27 Multiplication of an infinity by a finite non-zero value results in a |
|
28 signed infinity. The sign is determined by the rule already stated above. |
|
29 In the remaining cases, where neither an infinity or NaN is involved, the |
|
30 product is computed and rounded to the nearest representable value using IEEE |
|
31 754 round-to-nearest mode. If the magnitude is too large to represent, |
|
32 the result is then an infinity of appropriate sign. If the magnitude is |
|
33 oo small to represent, the result is then a zero |
|
34 of appropriate sign. The ECMAScript language requires support of gradual |
|
35 underflow as defined by IEEE 754. |
|
36 |
|
37 Author: christine@netscape.com |
|
38 Date: 12 november 1997 |
|
39 */ |
|
40 var SECTION = "11.5.1"; |
|
41 var VERSION = "ECMA_1"; |
|
42 startTest(); |
|
43 |
|
44 writeHeaderToLog( SECTION + " Applying the * operator"); |
|
45 |
|
46 new TestCase( SECTION, "Number.NaN * Number.NaN", Number.NaN, Number.NaN * Number.NaN ); |
|
47 new TestCase( SECTION, "Number.NaN * 1", Number.NaN, Number.NaN * 1 ); |
|
48 new TestCase( SECTION, "1 * Number.NaN", Number.NaN, 1 * Number.NaN ); |
|
49 |
|
50 new TestCase( SECTION, "Number.POSITIVE_INFINITY * 0", Number.NaN, Number.POSITIVE_INFINITY * 0 ); |
|
51 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 0", Number.NaN, Number.NEGATIVE_INFINITY * 0 ); |
|
52 new TestCase( SECTION, "0 * Number.POSITIVE_INFINITY", Number.NaN, 0 * Number.POSITIVE_INFINITY ); |
|
53 new TestCase( SECTION, "0 * Number.NEGATIVE_INFINITY", Number.NaN, 0 * Number.NEGATIVE_INFINITY ); |
|
54 |
|
55 new TestCase( SECTION, "-0 * Number.POSITIVE_INFINITY", Number.NaN, -0 * Number.POSITIVE_INFINITY ); |
|
56 new TestCase( SECTION, "-0 * Number.NEGATIVE_INFINITY", Number.NaN, -0 * Number.NEGATIVE_INFINITY ); |
|
57 new TestCase( SECTION, "Number.POSITIVE_INFINITY * -0", Number.NaN, Number.POSITIVE_INFINITY * -0 ); |
|
58 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -0", Number.NaN, Number.NEGATIVE_INFINITY * -0 ); |
|
59 |
|
60 new TestCase( SECTION, "0 * -0", -0, 0 * -0 ); |
|
61 new TestCase( SECTION, "-0 * 0", -0, -0 * 0 ); |
|
62 new TestCase( SECTION, "-0 * -0", 0, -0 * -0 ); |
|
63 new TestCase( SECTION, "0 * 0", 0, 0 * 0 ); |
|
64 |
|
65 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.NEGATIVE_INFINITY ); |
|
66 new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * Number.NEGATIVE_INFINITY ); |
|
67 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * Number.POSITIVE_INFINITY ); |
|
68 new TestCase( SECTION, "Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * Number.POSITIVE_INFINITY ); |
|
69 |
|
70 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * 1 ", Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY * 1 ); |
|
71 new TestCase( SECTION, "Number.NEGATIVE_INFINITY * -1 ", Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY * -1 ); |
|
72 new TestCase( SECTION, "1 * Number.NEGATIVE_INFINITY", Number.NEGATIVE_INFINITY, 1 * Number.NEGATIVE_INFINITY ); |
|
73 new TestCase( SECTION, "-1 * Number.NEGATIVE_INFINITY", Number.POSITIVE_INFINITY, -1 * Number.NEGATIVE_INFINITY ); |
|
74 |
|
75 new TestCase( SECTION, "Number.POSITIVE_INFINITY * 1 ", Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY * 1 ); |
|
76 new TestCase( SECTION, "Number.POSITIVE_INFINITY * -1 ", Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY * -1 ); |
|
77 new TestCase( SECTION, "1 * Number.POSITIVE_INFINITY", Number.POSITIVE_INFINITY, 1 * Number.POSITIVE_INFINITY ); |
|
78 new TestCase( SECTION, "-1 * Number.POSITIVE_INFINITY", Number.NEGATIVE_INFINITY, -1 * Number.POSITIVE_INFINITY ); |
|
79 |
|
80 test(); |
|
81 |