recursal/MDN huggingface dataset:
loop
====

The **`loop`** statement creates a label that can later be branched to with a `br`. The loop instruction doesn't loop by itself; you need to branch to it to actually create a loop.

The **`loop`** statement is the opposite of the `block` statement, in the sense that while branching to a `loop` jumps to the beginning of the loop, branching to a `block` jumps to the end of the block, that is, out of the block.

Try it
------

Syntax
------


```wasm
;; label the loop so that it can be branched to
(loop $my\_loop

  ;; branch to the loop.
  ;; most of the time you'll want to put this in an if statement and only branch on condition,
  ;; otherwise you have an infinite loop.
  br $my\_loop

)
```


| Instruction | Binary opcode |
| --- | --- |
| `loop` | `0x03` |
Select
======

The **`select`** instruction, selects one of its first two operands based on whether its third operand is zero or not. It shares some similarities with the ternary operator in other languages (e.g. `false ? 10 : 20`), but doesn't short-circuit. The instruction may be followed by an immediate value type: `select (result T)`. `select (result T)` uses a different binary opcode, and allows types besides those introduced by the WebAssembly MVP (`i32`, `i64`, `f32`, `f64`), for example, it allows selection between two `externref` values.

Try it
------

Syntax
------


```wasm
;; push two values onto the stack
i32.const 10
i32.const 20

;; change to `1` (true) to get the first value (`10`)
i32.const 0
select
```


```
f32.const nan
f32.const -54.1

;; change to `1` (true) to get the first value (`nan`)
i32.const 0
select (result f32)
```


| Instruction | Binary opcode |
| --- | --- |
| `select` | `0x1b` |
| `select t` | `0x1c` |
Drop
====

The **`drop`** instruction, pops a value from the stack, and discards it.

Try it
------

Syntax
------


```wasm
;; push multiple values onto the stack
i32.const 1
i32.const 2
i32.const 3

;; drop the top item from the stack (`3`)
drop

;; the top item on the stack will now be `2`
```


| Instruction | Binary opcode |
| --- | --- |
| `drop` | `0x1a` |
end
===

**`end`** is used to end a `block`, `loop`, `if`, or `else`. In the other examples we used the s-expression syntax which doesn't require the `end`, so you won't find it in the other examples here. However, it's still useful to know about since this is what the browsers display in devtools.

Try it
------

Syntax
------


```wasm
i32.const 0
if
  ;; do something
end
```


| Instruction | Binary opcode |
| --- | --- |
| `end` | `0x0b` |
nop
===

**`nop`** stands for no-operation. It literally does nothing.

Try it
------

Syntax
------


```wasm
nop
```


| Instruction | Binary opcode |
| --- | --- |
| `nop` | `0x01` |
br
==

The **`br`** statement branches to a loop, block, or if.

Other variants of `br` are `br_if` for branching on condition, and `br_table` for branching to different blocks based on an argument.

Try it
------

Syntax
------


```wasm
;; label the loop so that it can be branched to
(loop $my\_loop

  ;; branch to the loop.
  ;; most of the time you'll want to put this in an if statement and only branch on condition,
  ;; otherwise you have an infinite loop.
  br $my\_loop

)
```


| Instruction | Binary opcode |
| --- | --- |
| `br` | `0x0c` |
| `br_if` | `0x0d` |
| `br_table` | `0x0e` |
Local set
=========

The **`local.set`** instruction sets the values of a local variable.

Try it
------

Syntax
------


```wasm
;; load the number 2 onto the stack
i32.const 2

;; store the number 2 in the variable $val
local.set $val
```


| Instruction | Binary opcode |
| --- | --- |
| `local.set` | `0x21` |
Global get
==========

The **`global.get`** instruction loads the value of a global variable onto the stack.

Try it
------

Syntax
------


```wasm
;; load the value of a global variable onto the stack
global.get $val
```


| Instruction | Binary opcode |
| --- | --- |
| `global.get` | `0x23` |
Local
=====

The **`local`** instruction declares a new local variable.

Try it
------

Syntax
------


```wasm
;; declare new variable named $val of type i32
(local $val i32)
```
Local tee
=========

The **`local.tee`** instruction sets the value of a local variable and loads the value onto the stack.

The instruction is named after the T-splitter used in plumbing.

Try it
------

Syntax
------


```wasm
;; load the number 2 onto the stack
i32.const 2

;; store the number 2 in the variable $val and load it on the stack
local.tee $val
```


| Instruction | Binary opcode |
| --- | --- |
| `local.tee` | `0x22` |
Global
======

The **`global`** instruction declares a new global variable.

Try it
------

Syntax
------


```wasm
;; declare new variable named $val of type i32
(global $val i32)
```
Global set
==========

The **`global.set`** instruction sets the values of a global variable.

Try it
------

Syntax
------


```wasm
;; load the number 2 onto the stack
i32.const 2

;; store the number 2 in the variable $val
global.set $val
```


| Instruction | Binary opcode |
| --- | --- |
| `global.set` | `0x24` |
Local get
=========

The **`local.get`** instruction loads the value of a local variable onto the stack.

Try it
------

Syntax
------


```wasm
;; load the value of a local variable onto the stack
local.get $val
```


| Instruction | Binary opcode |
| --- | --- |
| `local.get` | `0x20` |
Greater or equal
================

The **`ge`** instructions, short for *greater or equal*, check if a number is greater than or equal to another number. If the first number is greater than or equal to the second number equal `1` will be pushed on to the stack, otherwise `0` will be pushed on to the stack.

The integer types have separate greater or equal instructions for signed (**`ge_s`**) and unsigned (**`ge_u`**) numbers.

Try it
------

Syntax
------


```wasm
;; load 2 numbers on to the stack
local.get $num
i32.const 2

;; check if $num is greater than or equal to '2'
i32.ge\_u

;; if $num is greater than or equal to the `2`, `1` will be pushed on to the stack,
;; otherwise `0` will be pushed on to the stack.
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.ge_s` | `0x4e` |
| `i32.ge_u` | `0x4f` |
| `i64.ge_s` | `0x59` |
| `i64.ge_u` | `0x5a` |
| `f32.ge` | `0x60` |
| `f64.ge` | `0x66` |
Addition
========

The **`add`** instructions, are used for adding up two numbers, similar to the **`+`** operator in other languages.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 10
i32.const 3

;; add up both numbers
i32.add

;; the top item on the stack will now be 13 (10 + 3 = 13)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.add` | `0x6a` |
| `i64.add` | `0x7c` |
| `f32.add` | `0x92` |
| `f64.add` | `0xa0` |
Square root
===========

The **`sqrt`** instructions, short for *square root*, are used to get the square root of a number.

Try it
------

Syntax
------


```wasm
;; load a number onto the stack
f32.const 289

;; get the square root of 289
f32.sqrt

;; the top item on the stack will now be 17
```


| Instruction | Binary opcode |
| --- | --- |
| `f32.sqrt` | `0x91` |
| `f64.sqrt` | `0x9f` |
Truncate (float to int)
=======================

The **`trunc`** instructions, are used for converting floating points to integers. It's named truncate since it truncates the fractional part of the number when doing the conversion. There are signed and unsigned versions of this instruction.

There's another **`trunc`** instruction that truncates the fractional part of a floating point without converting it to and integer.

Try it
------

Syntax
------


```wasm
;; push an f32 onto the stack
f32.const 10.5

;; convert from f32 to signed i32 rounding towards zero (.5 will be lost)
i32.trunc_f32_s

;; the top item on the stack will now be the value 10 of type f32
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.trunc_f32_s` | `0xa8` |
| `i32.trunc_f32_u` | `0xa9` |
| `i32.trunc_f64_s` | `0xaa` |
| `i32.trunc_f64_u` | `0xab` |
| `i64.trunc_f32_s` | `0xae` |
| `i64.trunc_f32_u` | `0xaf` |
| `i64.trunc_f64_s` | `0xb0` |
| `i64.trunc_f64_u` | `0xb1` |
Nearest
=======

The **`nearest`** instructions, are used for getting the value of a number rounded to the nearest integer.

Try it
------

Syntax
------


```wasm
;; load a number onto the stack
f32.const -2.7

;; round to the nearest integer
f32.nearest

;; the top item on the stack will now be -3
```


| Instruction | Binary opcode |
| --- | --- |
| `f32.nearest` | `0x90` |
| `f64.nearest` | `0x9e` |
Multiplication
==============

The **`mul`** instructions, short for *multiplication*, are used for multiplying one number by another number, similar to the **`*`** operator in other languages.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 10
i32.const 3

;; multiply one number by the other
i32.mul

;; the top item on the stack will now be 30 (10 \* 3 = 30)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.mul` | `0x6c` |
| `i64.mul` | `0x7e` |
| `f32.mul` | `0x94` |
| `f64.mul` | `0xa2` |
XOR
===

The **`xor`** instructions, are used for performing a bitwise XOR, similar to the **`^`** operator in other languages.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 5   ;; 00000101
i32.const 3   ;; 00000011

;; perform a bitwise XOR
i32.xor

;; the top item on the stack will now be 6 (00000110)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.xor` | `0x73` |
| `i64.xor` | `0x85` |
Not equal
=========

The **`ne`** instructions, short for *not equal*, check if two numbers are not equal. If the numbers are not equal `1` will be pushed on to the stack, otherwise `0` will be pushed on to the stack.

Try it
------

Syntax
------


```wasm
;; load 2 numbers on to the stack
local.get $num
i32.const 2

;; check if $num is not equal to '2'
i32.ne

;; if $num is not equal to `2`, `1` will be pushed on to the stack,
;; otherwise `0` will be pushed on to the stack.
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.ne` | `0x47` |
| `i64.ne` | `0x52` |
| `f32.ne` | `0x5c` |
| `f64.ne` | `0x62` |
Less than
=========

The **`lt`** instructions, short for *less than*, check if a number is less than another number. If the first number is less than the second number equal `1` will be pushed on to the stack, otherwise `0` will be pushed on to the stack.

The integer types have separate less than instructions for signed (**`lt_s`**) and unsigned (**`lt_u`**) numbers.

Try it
------

Syntax
------


```wasm
;; load 2 numbers on to the stack
local.get $num
i32.const 2

;; check if $num is less then '2'
i32.lt\_u

;; if $num is less than the `2`, `1` will be pushed on to the stack,
;; otherwise `0` will be pushed on to the stack.
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.lt_s` | `0x48` |
| `i32.lt_u` | `0x49` |
| `i64.lt_s` | `0x53` |
| `i64.lt_u` | `0x54` |
| `f32.lt` | `0x5d` |
| `f64.lt` | `0x63` |
Const
=====

The **`const`** instructions, are used to declare numbers.

Try it
------

Syntax
------


```wasm
;; push `5` onto the stack
i32.const 5
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.const` | `0x41` |
| `i64.const` | `0x42` |
| `f32.const` | `0x43` |
| `f64.const` | `0x44` |
Subtraction
===========

The **`sub`** instructions, short for *subtraction*, are used for subtracting one number from another number, similar to the **`-`** operator in other languages.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 10
i32.const 3

;; subtract one number from the other
i32.sub

;; the top item on the stack will now be 7 (10 - 3 = 7)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.sub` | `0x6b` |
| `i64.sub` | `0x7d` |
| `f32.sub` | `0x93` |
| `f64.sub` | `0xa1` |
Left shift
==========

The **`shl`** instructions, short for *shift-left*, are used for performing a bitwise left-shift, similar to the **`<<`** operator in other languages.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 7   ;; 00000111
i32.const 1   ;; left shift one spot

;; perform a bitwise left-shift
i32.shl

;; the top item on the stack will now be 14 (00001110)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.shl` | `0x74` |
| `i64.shl` | `0x86` |
Less or equal
=============

The **`le`** instructions, short for *less or equal*, check if a number is less than or equal to another number. If the first number is less than or equal to the second number equal `1` will be pushed on to the stack, otherwise `0` will be pushed on to the stack.

The integer types have separate less or equal instructions for signed (**`le_s`**) and unsigned (**`le_u`**) numbers.

Try it
------

Syntax
------


```wasm
;; load 2 numbers on to the stack
local.get $num
i32.const 2

;; check if $num is less then or equal to '2'
i32.le\_u

;; if $num is less than or equal to the `2`, `1` will be pushed on to the stack,
;; otherwise `0` will be pushed on to the stack.
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.le_s` | `0x4C` |
| `i32.le_u` | `0x4D` |
| `i64.le_s` | `0x57` |
| `i64.le_u` | `0x58` |
| `f32.le` | `0x5F` |
| `f64.le` | `0x65` |
Division
========

The **`div`** instructions, short for *division*, are used for dividing one number by another, similar to the **`/`** operator in other languages.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 12
i32.const 3

;; divide one number by the other
i32.div\_u

;; the top item on the stack will now be 4 (12 / 3 = 4)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.div_s` | `0x6d` |
| `i32.div_u` | `0x6e` |
| `i64.div_s` | `0x7f` |
| `i64.div_u` | `0x80` |
| `f32.div` | `0x95` |
| `f64.div` | `0xa3` |
Reinterpret
===========

The **`reinterpret`** instructions, are used to reinterpret the bits of a number as a different type.

Try it
------

Syntax
------


```wasm
;; the value `10000000\_00000000\_00000000\_00000000` in binary
;; maps to `-0` as a floating point and to `-2147483648` as an integer

;; push an f32 onto the stack
f32.const -0

;; reinterpret the bytes of the f32 as i32
i32.reinterpret_f32

;; the top item on the stack will now be the value -2147483648 of type i32
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.reinterpret_f32` | `0xbc` |
| `i64.reinterpret_f64` | `0xbd` |
| `f32.reinterpret_i32` | `0xbe` |
| `f64.reinterpret_i64` | `0xbf` |
Right rotate
============

The **`rotr`** instructions, short for *rotate-right*, are used for performing a bitwise right-rotate.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 7   ;; 00000000\_00000000\_00000000\_00000111
i32.const 1   ;; right rotate one spot

;; perform a bitwise right-rotate
i32.rotr

;; the top item on the stack will now be 2147483651
;; (10000000\_00000000\_00000000\_00000011)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.rotr` | `0x78` |
| `i64.rotr` | `0x8a` |
AND
===

The **`and`** instructions, are used for performing a bitwise AND, similar to the **`&`** operator in other languages.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 5   ;; 00000101
i32.const 3   ;; 00000011

;; perform a bitwise AND
i32.and

;; the top item on the stack will now be 1 (00000001)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.and` | `0x71` |
| `i64.and` | `0x83` |
Right shift
===========

The **`shr`** instructions, short for *shift-right*, are used for performing a bitwise right-shift, similar to the **`>>>`** operator in other languages.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 7   ;; 00000111
i32.const 1   ;; right shift one spot

;; perform a bitwise right-shift
i32.shr\_u

;; the top item on the stack will now be 3 (00000011)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.shr_s` | `0x75` |
| `i32.shr_u` | `0x76` |
| `i64.shr_s` | `0x87` |
| `i64.shr_u` | `0x88` |
Ceil
====

The **`ceil`** instructions, are used for getting the value of a number rounded up to the next integer.

Try it
------

Syntax
------


```wasm
;; load a number onto the stack
f32.const 2.7

;; round up
f32.ceil

;; the top item on the stack will now be 3
```


| Instruction | Binary opcode |
| --- | --- |
| `f32.ceil` | `0x8d` |
| `f64.ceil` | `0x9b` |
Count trailing zeros
====================

The **`ctz`** instructions, short for *count trailing zeros*, are used to count the amount of zeros at the end of the numbers binary representation.

Try it
------

Syntax
------


```wasm
;; load a number onto the stack
i32.const 8388608 ;; 00000000\_10000000\_00000000\_00000000

;; count trailing zeros
i32.ctz

;; the top item on the stack will now be 23
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.ctz` | `0x68` |
| `i64.ctz` | `0x7a` |
OR
==

The **`or`** instructions, are used for performing a bitwise OR, similar to the **`|`** operator in other languages.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 5   ;; 00000101
i32.const 3   ;; 00000011

;; perform a bitwise OR
i32.or

;; the top item on the stack will now be 7 (00000111)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.or` | `0x72` |
| `i64.or` | `0x84` |
Wrap
====

The **`wrap`** instruction, is used to convert numbers of type `i64` to type `i32`. If the number is larger than what an `i32` can hold this operation will wrap, resulting in a different number.

One can think of wrap either as reducing the value mod 232, or as discarding the high 32 bits to produce a value containing just the low 32 bits.

Try it
------

Syntax
------


```wasm
;; push an i64 onto the stack
i64.const 10

;; wrap from i64 to i32
i32.wrap_i64

;; the top item on the stack will now be the value 10 of type `i32`
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.wrap_i64` | `0xa7` |
Absolute
========

The **`abs`** instructions, short for *absolute*, are used to get the absolute value of a number. That is, it returns x if x is positive, and the negation of x if x is negative.

Try it
------

Syntax
------


```wasm
;; load a number onto the stack
f32.const -2

;; absolute
f32.abs

;; the top item on the stack will now be 2
```


| Instruction | Binary opcode |
| --- | --- |
| `f32.abs` | `0x8b` |
| `f64.abs` | `0x99` |
Equal
=====

The **`eq`** instructions, short for *equal*, check if two numbers are equal. If both numbers are equal `1` will be pushed on to the stack, otherwise `0` will be pushed on to the stack.

Similarly, the **`eqz`** instructions check if a number is equal to zero, the **`eqz`** instructions are only available for the integer types and not for the floating point types.

Try it
------

Syntax
------


```wasm
;; load 2 numbers on to the stack
local.get $num
i32.const 2

;; check if $num is equal to '2'
i32.eq

;; if $num is equal to `2`, `1` will be pushed on to the stack,
;; otherwise `0` will be pushed on to the stack.
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.eqz` | `0x45` |
| `i32.eq` | `0x46` |
| `i64.eqz` | `0x50` |
| `i64.eq` | `0x51` |
| `f32.eq` | `0x5b` |
| `f64.eq` | `0x61` |
Count leading zeros
===================

The **`clz`** instructions, short for *count leading zeros*, are used to count the amount of zeros at the start of the numbers binary representation.

Try it
------

Syntax
------


```wasm
;; load a number onto the stack
i32.const 8388608 ;; 00000000\_10000000\_00000000\_00000000

;; count leading zeros
i32.clz

;; the top item on the stack will now be 8
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.clz` | `0x67` |
| `i64.clz` | `0x79` |
Convert
=======

The **`convert`** instructions, are used for converting integer numbers to floating point numbers. There are signed and unsigned versions of this instruction.

Try it
------

Syntax
------


```wasm
;; push an i32 onto the stack
i32.const 10

;; convert from signed i32 to f32
f32.convert_i32_s

;; the top item on the stack will now be the value 10 of type f32
```


| Instruction | Binary opcode |
| --- | --- |
| `f32.convert_i32_s` | `0xb2` |
| `f32.convert_i32_u` | `0xb3` |
| `f32.convert_i64_s` | `0xb4` |
| `f32.convert_i64_u` | `0xb5` |
| `f64.convert_i32_s` | `0xb7` |
| `f64.convert_i32_u` | `0xb8` |
| `f64.convert_i64_s` | `0xb9` |
| `f64.convert_i64_u` | `0xba` |
Greater than
============

The **`gt`** instructions, short for *greater than*, check if a number is greater than another number. If the first number is greater than the second number equal `1` will be pushed on to the stack, otherwise `0` will be pushed on to the stack.

The integer types have separate greater than instructions for signed (**`gt_s`**) and unsigned (**`gt_u`**) numbers.

Try it
------

Syntax
------


```wasm
;; load 2 numbers on to the stack
local.get $num
i32.const 2

;; check if $num is greater than '2'
i32.gt\_u

;; if $num is greater than the `2`, `1` will be pushed on to the stack,
;; otherwise `0` will be pushed on to the stack.
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.gt_s` | `0x4a` |
| `i32.gt_u` | `0x4b` |
| `i64.gt_s` | `0x55` |
| `i64.gt_u` | `0x56` |
| `f32.gt` | `0x5e` |
| `f64.gt` | `0x64` |
Promote
=======

The **`promote`** instruction, is used to convert (promote) numbers of type `f32` to type `f64`.

Try it
------

Syntax
------


```wasm
;; push an f32 onto the stack
f32.const 10.5

;; promote from f32 to f64
f64.promote_f32

;; the top item on the stack will now be the value 10.5 of type f64
```


| Instruction | Binary opcode |
| --- | --- |
| `f64.promote_f32` | `0xbb` |
Min
===

The **`min`** instructions, are used for getting the lower of two numbers.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
f32.const 10
f32.const 3

;; get lower number
f32.min

;; the top item on the stack will now be 3
```


| Instruction | Binary opcode |
| --- | --- |
| `f32.min` | `0x96` |
| `f64.min` | `0xa4` |
Max
===

The **`max`** instructions, are used for getting the higher of two numbers.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
f32.const 10
f32.const 3

;; get higher number
f32.max

;; the top item on the stack will now be 10
```


| Instruction | Binary opcode |
| --- | --- |
| `f32.max` | `0x97` |
| `f64.max` | `0xa5` |
Left rotate
===========

The **`rotl`** instructions, short for *rotate-left*, are used for performing a bitwise left-rotate.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 3758096384 ;; 11100000\_00000000\_00000000\_00000000
i32.const 1          ;; left rotate one spot

;; perform a bitwise left-rotate
i32.rotl

;; the top item on the stack will now be 3221225473
;; (11000000\_00000000\_00000000\_00000001)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.rotl` | `0x77` |
| `i64.rotl` | `0x89` |
Remainder
=========

The **`rem`** instructions, short for *remainder*, are used to calculate the remainder left over when one integer is divided by another integer, similar to the **`%`** operator in other languages. The **`rem`** instructions are only available for the integer types and not for the floating point types.

Try it
------

Syntax
------


```wasm
;; load two numbers onto the stack
i32.const 10
i32.const 3

;; calculate the remainder of dividing one number by the other
i32.rem

;; the top item on the stack will now be 1 (10 % 3 = 1)
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.rem_s` | `0x6f` |
| `i32.rem_u` | `0x70` |
| `i64.rem_s` | `0x81` |
| `i64.rem_u` | `0x82` |
Negate
======

The **`neg`** instructions, short for *negate*, are used to negate a number. That is, turn a positive number into a negative number and a negative number into a positive number.

Try it
------

Syntax
------


```wasm
;; load a number onto the stack
f32.const 2.7

;; negate
f32.neg

;; the top item on the stack will now be -2.7
```


| Instruction | Binary opcode |
| --- | --- |
| `f32.neg` | `0x8c` |
| `f64.neg` | `0x9a` |
Population count
================

The **`popcnt`** instructions, short for *population count*, are used to count the amount of `1`s in a numbers binary representation.

Try it
------

Syntax
------


```wasm
;; load a number onto the stack
i32.const 130 ;; 10000010

;; count the 1s
i32.popcnt

;; the top item on the stack will now be 2
```


| Instruction | Binary opcode |
| --- | --- |
| `i32.popcnt` | `0x69` |
| `i64.popcnt` | `0x7b` |