Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
case '4': // 10 的 x 次幂
res.innerHTML = result = math.format(math.pow(10, result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
case '5': // 1/x
res.innerHTML = result = math.format(math.divide(1, result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
case '6': // x 开平方根
res.innerHTML = result = math.format(math.sqrt(result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
case '7': // x 开立方根
res.innerHTML = result = math.format(math.cbrt(result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
case '8': // x 的开 y 次方根
_this.events = event;
if (!event.classList.contains('active')) {
if (_this.register.ope === '8') {
case '18': // 底数为 e 的对数
res.innerHTML = result = math.format(math.log(result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
case '19': // 底数为 10 的对数
res.innerHTML = result = math.format(math.log10(result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
case '20': // e 的指数
res.innerHTML = result = math.format(math.exp(result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
default:
break;
}
},
case '13': // sinh 双曲正弦
res.innerHTML = result = math.format(math.sinh(result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
case '14': // cosh 双曲余弦
res.innerHTML = result = math.format(math.cosh(result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
case '15': // tanh 双曲正切
res.innerHTML = result = math.format(math.tanh(result), {
precision: 16
});
_this.register.ope = type;
_this.isEqual = true;
break;
case '16': // 圆周率
res.innerHTML = result = Math.PI;
_this.register.ope = type;
_this.isEqual = true;
break;
case '17': // x 的阶乘
if (result.indexOf('.') > -1 || result.indexOf('-') > -1) {
_this.reset();
res.innerHTML = 'error';
} else {
res.innerHTML = result = math.factorial(result);
steps = Mathjs.bignumber(Math.pow(2, n));
} else if (complexity == 'factorial') {
n = Mathjs.bignumber(n);
steps = Mathjs.factorial(n);
}
var denominator = Mathjs.multiply(speed, processors);
var timeTaken = Mathjs.divide(steps, denominator);
var timeScale = Mathjs.bignumber(TIME_SCALERS[timeUnits])
timeTaken = Mathjs.multiply(timeTaken, timeScale);
if (resultForm == 'scientific') {
timeTaken = Mathjs.format(Mathjs.bignumber(timeTaken), {notation: 'exponential', precision: 3});
} else {
timeTaken = Mathjs.format(Mathjs.bignumber(timeTaken), {notation: 'fixed', precision: 2});
// If there are no significant decimal places don't show any decimal places (non scientific mode only)
if (timeTaken % 1 == 0) {
timeTaken = Mathjs.format(Mathjs.bignumber(timeTaken), {notation: 'fixed', precision: 0});
}
}
return timeTaken;
}
function printRatio (value) {
console.log(math.format(value, { fraction: 'ratio' }))
}
function print (value) {
const precision = 14
console.log(math.format(value, precision))
}
function print (value) {
const precision = 14
console.log(math.format(value, precision))
}
function print (value) {
console.log(math.format(value, { fraction: 'decimal' }))
}
return new Promise(function (resolve, reject) {
if(!isNaN(values[0])) {
reject("Don't allow function identity", {module : "calculator"});
} else {
values[0] = values[0].toLowerCase();
values[0] = values[0].replace("×","*");
values[0] = values[0].replace("x","*");
values[0] = values[0].replace("÷","/");
values[0] = values[0].replace("¹", "^1");
values[0] = values[0].replace("²", "^2");
values[0] = values[0].replace("³", "^3");
try {
var response = math.eval(values[0]);
response = math.format(response, {precision: 14});
if(response === 'function') {
reject("The query is poorly formulated", {module : "calculator"});
}
if (response['signatures']) {
resolve(0);
} else {
if (response === Infinity) {
throw 500;
} else {
resolve(response.toString());
}
}
} catch (e) {
reject("Your formula isn't valid", {module : "calculator"});
}
}
this._outgoingConnection = null;
this._previousIncomingConnections = null;
this._previousOutgoingConnections = null;
this._previousWeight = m.bignumber(0);
this._previousWeightChange = m.bignumber(0);
this._weight = m.subtract(
m.bignumber(1),
m.multiply(
m.bignumber(
m.format(
m.random(0, 1),
{
notation: "fixed",
precision: 15
}
)
),
m.bignumber(2)
)
);
this._weightChange = m.bignumber(0);
};