You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
664 B
25 lines
664 B
// 20.2.2.17 Math.hypot([value1[, value2[, … ]]]) |
|
var $export = require('./_export'); |
|
var abs = Math.abs; |
|
|
|
$export($export.S, 'Math', { |
|
hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars |
|
var sum = 0; |
|
var i = 0; |
|
var aLen = arguments.length; |
|
var larg = 0; |
|
var arg, div; |
|
while (i < aLen) { |
|
arg = abs(arguments[i++]); |
|
if (larg < arg) { |
|
div = larg / arg; |
|
sum = sum * div * div + 1; |
|
larg = arg; |
|
} else if (arg > 0) { |
|
div = arg / larg; |
|
sum += div * div; |
|
} else sum += arg; |
|
} |
|
return larg === Infinity ? Infinity : larg * Math.sqrt(sum); |
|
} |
|
});
|
|
|