export function parseFormula(formula: string): number {
    const f = formula.trim().replace(/\s/g, '');

    const pct = f.match(/^(-?\d+(?:\.\d+)?)-(-?\d+(?:\.\d+)?)%$/);
    if (pct) return Math.round(((parseFloat(pct[1]) * parseFloat(pct[2])) / 100) * 100) / 100;

    const mul = f.match(/^(-?\d+(?:\.\d+)?)\*(-?\d+(?:\.\d+)?)$/);
    if (mul) return Math.round(parseFloat(mul[1]) * parseFloat(mul[2]) * 100) / 100;

    const num = f.match(/^(-?\d+(?:\.\d+)?)$/);
    if (num) return parseFloat(num[1]);

    return 0;
}
