WebAssembly Data Types

WebAssembly (as of v1.0) has only four data types.

  • i32 : 32 Bit Integer
  • i64 : 64 Bit Integer
  • f32 : 32 Bit Floating Point Number
  • f64 : 64 Bit Floating Point Number

Usage of i32 for addition


(module
  (func $addi32 (param $lhs i32) (param $rhs i32) (result i32)
    get_local $lhs
    get_local $rhs
    i32.add)
  (export "addi32" (func $addi32))
)
            

Usage of i64 for addition


(module
  (func $addi64 (param $lhs i64) (param $rhs i64) (result i64)
    get_local $lhs
    get_local $rhs
    i64.add)
  (export "addi64" (func $addi64))
)
            

Usage of f32 for addition


(module
  (func $add (param $lhs f32) (param $rhs f32) (result f32)
    get_local $lhs
    get_local $rhs
    f32.add)
  (export "addf32" (func $addf32))
)
            

Usage of f64 for addition


(module
  (func $addf64 (param $lhs f64) (param $rhs f64) (result f64)
    get_local $lhs
    get_local $rhs
    f64.add)
  (export "addf64" (func $addf64))
)