wallet-core/node_modules/core-js/modules/es6.math.hypot.js

26 lines
664 B
JavaScript
Raw Normal View History

2016-10-10 03:43:44 +02:00
// 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
2017-08-14 05:01:11 +02:00
var $export = require('./_export');
var abs = Math.abs;
2016-10-10 03:43:44 +02:00
$export($export.S, 'Math', {
2017-08-14 05:01:11 +02:00
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) {
2017-05-27 17:36:13 +02:00
arg = abs(arguments[i++]);
2017-08-14 05:01:11 +02:00
if (larg < arg) {
div = larg / arg;
sum = sum * div * div + 1;
2016-10-10 03:43:44 +02:00
larg = arg;
2017-08-14 05:01:11 +02:00
} else if (arg > 0) {
div = arg / larg;
2016-10-10 03:43:44 +02:00
sum += div * div;
} else sum += arg;
}
return larg === Infinity ? Infinity : larg * Math.sqrt(sum);
}
2017-08-14 05:01:11 +02:00
});