> 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/round.md).

# Round

Rounds to the nearest whole number. 0.5 is rounded up.

```javascript
(module
  (func $fract (export "fract") (param $x f32) (result f32)
    (f32.sub
      (get_local $x)
      (f32.floor (get_local $x))
    )
  )
  (func $round (export "round") (param $x f32) (result f32)
    get_local $x
    call $fract
    f32.const 0.5
    f32.ge
    if $i0
      get_local $x
      f32.ceil 
      return
    end
    get_local $x
    f32.floor 
  )
)
```
