# suboptimal-float-operation

Prefer faster floating-point operations when their precision is sufficient

General floating-point formulas can require extra instructions or rounding steps when a dedicated operation exists.
Instead, you SHOULD call the dedicated floating-point method.

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

## Reported

```ds title="main.ds"
function root(value: float64): float64 {
    return value ** 0.5;
}
```

## Accepted

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

## Prior art

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

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