|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
822 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var $TypeError = require('es-errors/type');
|
|---|
| 4 | var isFinite = require('math-intrinsics/isFinite');
|
|---|
| 5 |
|
|---|
| 6 | var isNaN = require('../../helpers/isNaN');
|
|---|
| 7 |
|
|---|
| 8 | // https://262.ecma-international.org/11.0/#sec-numeric-types-number-multiply
|
|---|
| 9 |
|
|---|
| 10 | module.exports = function NumberMultiply(x, y) {
|
|---|
| 11 | if (typeof x !== 'number' || typeof y !== 'number') {
|
|---|
| 12 | throw new $TypeError('Assertion failed: `x` and `y` arguments must be Numbers');
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | if (isNaN(x) || isNaN(y) || (x === 0 && !isFinite(y)) || (!isFinite(x) && y === 0)) {
|
|---|
| 16 | return NaN;
|
|---|
| 17 | }
|
|---|
| 18 | if (!isFinite(x) && !isFinite(y)) {
|
|---|
| 19 | return x === y ? Infinity : -Infinity;
|
|---|
| 20 | }
|
|---|
| 21 | if (!isFinite(x) && y !== 0) {
|
|---|
| 22 | return x > 0 ? Infinity : -Infinity;
|
|---|
| 23 | }
|
|---|
| 24 | if (!isFinite(y) && x !== 0) {
|
|---|
| 25 | return y > 0 ? Infinity : -Infinity;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | // shortcut for the actual spec mechanics
|
|---|
| 29 | return x * y;
|
|---|
| 30 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.