f64.nearest
Pops a f64 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

f64.nearest

Stack In

f64 The value to round.

Stack Out

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

Examples

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

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

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

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

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

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

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

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

;; The stack contains an f64 value of 3.0