fix(est): match project costs and stored formulas
This commit is contained in:
@@ -26,7 +26,12 @@ const EstMath = (() => {
|
||||
}
|
||||
function floating(value, digits = 0, method = 2) {
|
||||
const k = 10 ** digits;
|
||||
return mode((value + Math.sign(value) * 2e-10) * k, method) / k;
|
||||
// The original keeps x87 extended intermediates. Account for one binary64
|
||||
// rounding unit before truncation so exact decimal boundaries survive JS.
|
||||
const scaled = value * k;
|
||||
return (
|
||||
mode(scaled + Math.sign(value) * (2e-10 * k + Number.EPSILON * Math.abs(scaled)), method) / k
|
||||
);
|
||||
}
|
||||
function precision(row, fallback = 0) {
|
||||
return num(row.DigetIndex)
|
||||
@@ -63,7 +68,9 @@ const EstMath = (() => {
|
||||
const result = Object.fromEntries(
|
||||
components.map((key) => [
|
||||
key,
|
||||
floating(rows.filter(predicate).reduce((n, row) => n + num(row[key]), 0)),
|
||||
floating(
|
||||
rows.filter(predicate).reduce((n, row) => n + even(num(row[key]) * 10000), 0) / 10000,
|
||||
),
|
||||
]),
|
||||
);
|
||||
result.TC = sum(result);
|
||||
|
||||
Reference in New Issue
Block a user