mirror of
https://github.com/IvarK/AntimatterDimensionsSourceCode.git
synced 2024-11-24 21:21:59 +00:00
Codefactor changes, comment improvement
This commit is contained in:
parent
12958ccd9d
commit
bd02e7e394
@ -514,13 +514,14 @@ window.logFactorial = (function() {
|
||||
};
|
||||
}());
|
||||
|
||||
window.exp1m = function (x) {
|
||||
window.exp1m = function(x) {
|
||||
if (x.abs().gte(0.001)) {
|
||||
return x.exp().minus(1);
|
||||
} else {
|
||||
// Probably just figuring out these are the only terms needed is faster than calculating all the terms.
|
||||
return x.plus(x.pow(2).div(2)).plus(x.pow(3).div(6)).plus(x.pow(4).div(24)).plus(x.pow(5).div(120));
|
||||
}
|
||||
// This sum contains all the terms that are relevant for |x| < 0.001. We could do some sort of loop
|
||||
// (add terms as long as they matter) but that probably has a greater fixed overhead, and we don't
|
||||
// call this enough for efficiency to be very worrying anyway.
|
||||
return x.plus(x.pow(2).div(2)).plus(x.pow(3).div(6)).plus(x.pow(4).div(24)).plus(x.pow(5).div(120));
|
||||
};
|
||||
|
||||
/** 32 bit XORSHIFT generator */
|
||||
|
Loading…
Reference in New Issue
Block a user