> For the complete documentation index, see [llms.txt](https://augustus-pash.gitbook.io/wasm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://augustus-pash.gitbook.io/wasm/maths-algorithms/clamp.md).

# Clamp

Forces x to be between or the min and max range.

```javascript
(module
  (func $clamp (export "clamp") (param $x f32) (param $min f32) (param $max f32) (result f32)
    (f32.min
      (f32.max
        (get_local $x)
        (get_local $min)
      )
      (get_local $max)
    )
  )
)
```
