quaeratin
Version:
An extended precision floating point library (as per Shewchuk) - precision only limited by overflow / underflow
27 lines (19 loc) • 569 B
text/typescript
import { eSign } from "./e-sign.js";
import { eNegativeOf } from "./e-negative-of.js";
// We *have* to do the below❗ The assignee is a getter❗ The assigned is a pure function❗
const sign = eSign;
const negativeOf = eNegativeOf;
/**
* Returns the absolute value of the given floating point expansion.
*
* * see [Shewchuk](https://people.eecs.berkeley.edu/~jrs/papers/robustr.pdf)
*
* @param e a floating point expansion
*/
function eAbs(e: number[]) {
if (e[e.length-1] < 0) {
return negativeOf(e);
}
return e;
}
export { eAbs }