main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1009 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 |
|
---|
4 | // eslint-disable-next-line es/no-math-hypot -- required for testing
|
---|
5 | var $hypot = Math.hypot;
|
---|
6 | var abs = Math.abs;
|
---|
7 | var sqrt = Math.sqrt;
|
---|
8 |
|
---|
9 | // Chrome 77 bug
|
---|
10 | // https://bugs.chromium.org/p/v8/issues/detail?id=9546
|
---|
11 | var FORCED = !!$hypot && $hypot(Infinity, NaN) !== Infinity;
|
---|
12 |
|
---|
13 | // `Math.hypot` method
|
---|
14 | // https://tc39.es/ecma262/#sec-math.hypot
|
---|
15 | $({ target: 'Math', stat: true, arity: 2, forced: FORCED }, {
|
---|
16 | // eslint-disable-next-line no-unused-vars -- required for `.length`
|
---|
17 | hypot: function hypot(value1, value2) {
|
---|
18 | var sum = 0;
|
---|
19 | var i = 0;
|
---|
20 | var aLen = arguments.length;
|
---|
21 | var larg = 0;
|
---|
22 | var arg, div;
|
---|
23 | while (i < aLen) {
|
---|
24 | arg = abs(arguments[i++]);
|
---|
25 | if (larg < arg) {
|
---|
26 | div = larg / arg;
|
---|
27 | sum = sum * div * div + 1;
|
---|
28 | larg = arg;
|
---|
29 | } else if (arg > 0) {
|
---|
30 | div = arg / larg;
|
---|
31 | sum += div * div;
|
---|
32 | } else sum += arg;
|
---|
33 | }
|
---|
34 | return larg === Infinity ? Infinity : larg * sqrt(sum);
|
---|
35 | }
|
---|
36 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.