menu

imprecise-float-operation

Prefer numerically stable floating-point operations

Expanded cube-root, logarithm, and exponential formulas lose precision through intermediate rounding and cancellation. Instead, you SHOULD call the dedicated floating-point method.

Reported

1function offsetLog(value: float64): float64 {2    return (1.0 + value).log();3}

Accepted

1function offsetLog(value: float64): float64 {2    return value.log1p();3}