# 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.

- Category: correctness
- Level: warning
- Fix: suggestion
- Scope: module

## Reported

```ds title="main.ds"
function offsetLog(value: float64): float64 {
    return (1.0 + value).log();
}
```

## Accepted

```ds title="main.ds"
function offsetLog(value: float64): float64 {
    return value.log1p();
}
```

## Prior art

- [Clippy · imprecise_flops](https://rust-lang.github.io/rust-clippy/master/index.html#imprecise_flops)

[language/linter/src/rules/correctness/imprecise_float_operation.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/correctness/imprecise_float_operation.rs#L8)
