# Numbers

Wasm has four types of numbers i32, i64, f32, and f64. Each kind has their own operators and can be converted between types.

i32 - 32bit integer\
i64 - 64bit integer\
f32 - 32bit float\
f64 - 64bit float

### Define a Const

```javascript
i32.const 1
i64.const 1
f32.const 1
f64.const 1
```

### Common Arithmetic

|             | i32                    | i64        | f32       | f64       |
| ----------- | ---------------------- | ---------- | --------- | --------- |
| add         | i32.add                | i64.add    | f32.add   | f64.add   |
| sub         | i32.sub                | i64.sub    | f32.sub   | f64.sub   |
| mul         | i32.mul                | i64.mul    | f32.mul   | f64.mul   |
| div         | i32.div\_s //signed    | i64.div\_s | f32.div   | f64.div   |
|             | I32.div\_u  //unsigned | i64.div\_u |           |           |
| modulus     | i32.rem\_s             | i64.rem\_s |           |           |
|             | i32.rem\_u             | i64.rem\_u |           |           |
| abs         |                        |            | f32.abs   | f64.abs   |
| neg         |                        |            | f32.neg   | f64.neg   |
| ceiling     |                        |            | f32.ceil  | f64.ceil  |
| floor       |                        |            | f32.floor | f64.floor |
| square root |                        |            | f32.sqrt  | f64.sqrt  |
| min         |                        |            | f32.min   | f64.min   |
| max         |                        |            | f64.max   | f64.max   |

### Common Logic

|                       | i32                  | i64       | f32    | f64    |
| --------------------- | -------------------- | --------- | ------ | ------ |
| equals one            | i32.eqz              | i64.eqz   |        |        |
| equals                | i32.eq               | i64.eq    | f32.eq | f64.eq |
| not equal             | i32.ne               | i64.ne    | f32.ne | f64.ne |
| less than             | i32.lt\_s //signed   | i64.lt\_s | f32.lt | f64.lt |
|                       | i32.lt\_u //unsigned | i64.lt\_u |        |        |
| greater than          | i32.gt\_s            | i64.gt\_s | f32.gt | f64.gt |
|                       | i32.gt\_u            | i64.gt\_u |        |        |
| less then or equal    | i32.le\_s            | i64.le\_s | f32.le | f64.le |
|                       | i32.le\_u            | i64.le\_u |        |        |
| greater than or equal | i32.ge\_s            | i64.ge\_s | f32.ge | f64.ge |
|                       | i32.ge\_u            | i64.ge\_u |        |        |
| and                   | i32.and              | i64.and   |        |        |
| or                    | i32.or               | i64.or    |        |        |
| xor                   | i32.xor              | i64.xor   |        |        |

### Conversions

| x to y | i32                 | i64                 | f32               | f64               |
| ------ | ------------------- | ------------------- | ----------------- | ----------------- |
| i32    |                     | i32.wrap\_i64       | i32.trunc\_f32\_s | i32.trunc\_f64\_s |
| i64    | i64.extend\_i32\_s  |                     | i64.trunc\_f32\_u | i64.trunc\_f64\_s |
| f32    | f32.convert\_i32    | f32.convert\_i64\_s |                   | f32.demote\_f64   |
| f64    | f64.convert\_i32\_s | f64.convert\_i64\_s | f64.promote\_f32  |                   |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://augustus-pash.gitbook.io/wasm/types/numbers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
