f32.nearest
Pops a f32 value off the stack, works out the nearest value, and then pushes the result back on to the stack. This rounds the value to the nearest whole number and removes any decimal parts. For example, 1.23 is rounded to 1.0, and 1.63 is rounded to 2.0. Anything 0.5 and below is rounded down and everything above 0.5 is rounded up.

Syntax

f32.nearest

Stack In

f32 The value to round.

Stack Out

f32 The result of rounding the value to the nearest whole number.

Examples

;; Push the f32 value 1.23 onto the stack
f32.const 1.23

;; Pop the f32 value off the stack, round to the nearest value and
;; push the result back onto the stack
f32.nearest

;; The stack contains an f32 value of 1.0
;; Push the f32 value 2.65 onto the stack
f32.const 2.65

;; Pop the f32 value off the stack, round to the nearest value and
;; push the result back onto the stack
f32.nearest

;; The stack contains an f32 value of 3.0
;; Push the f32 value -2.65 onto the stack
f32.const -2.65

;; Pop the f32 value off the stack, round to the nearest value and
;; push the result back onto the stack
f32.nearest

;; The stack contains an f32 value of -3.0
;; Push the f32 value 3.5 onto the stack
f32.const 3.5

;; Pop the f32 value off the stack, round to the nearest value and
;; push the result back onto the stack
f32.nearest

;; The stack contains an f32 value of 3.0