f64.copysign
Pops two f64 values off the stack, gives the sign of the second one (either plus or minus) to the first value, and then pushes it back on to the stack. If the second value is negative then this makes sure the first value is also negative and pushes the result onto the stack.

Syntax

f64.copysign

Stack In

f64 The value to have its sign reset if required.
f64 The value sign the result must have.

Stack Out

f64 The first value with the sign that matches the second value.

Examples

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

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

;; Pop the two f64 values off the stack, copy the sign part
;; and push it back onto the stack
f64.copysign

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

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

;; Pop the two f64 values off the stack, copy the sign part
;; and push it back onto the stack
f64.copysign

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

;; Push the f64 value -2.718 onto the stack
f64.const -2.718

;; Pop the two f64 values off the stack, copy the sign part
;; and push it back onto the stack
f64.copysign

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

;; Push the f64 value -2.718 onto the stack
f64.const -2.718

;; Pop the two f64 values off the stack, copy the sign part
;; and push it back onto the stack
f64.copysign

;; The stack contains an f64 value of -3.142