ballercat/walt

Unsigned integers

Open

#120 创建于 2018年5月19日

在 GitHub 查看
 (2 评论) (2 反应) (0 负责人)JavaScript (155 fork)batch import
enhancementhelp wantedmoderate

仓库指标

Star
 (4,637 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Feature Request

Overview

Walt currently supports only signed integers and signed operations. Since WebAssembly also supports unsigned operations, it would be really neat to also have unsigned types u32 and u64. These operations should be used:

  • i32.div_u and i64.div_u (x / y)
  • i32.rem_u and i64.rem_u (x % y)
  • i32.shr_u and i64.shr_u (x >> y)
  • i32.lt_u and i64.lt_u (x < y)
  • i32.le_u and i64.le_u (x <= y)
  • i32.gt_u and i64.gt_u (x > y)
  • i32.ge_u and i64.ge_u (x >= y)
  • i64.load32_u (const x: u32 = 10; const y: u64 = x;)
  • i32.trunc_u/f32 (const x: f32 = 10; const y: u32 = x;)
  • i32.trunc_u/f64 (const x: f64 = 10; const y: u32 = x;)
  • i64.extend_u/i32 (const x: u32 = 10; const y: u64 = x;)
  • i64.trunc_u/f32 (const x: f32 = 10; const y: u64 = x;)
  • i64.trunc_u/f64 (const x: f64 = 10; const y: u64 = x;)
  • f32.convert_u/i32 (const x: u32 = 10; const y: f32 = x;)
  • f32.convert_u/i64 (const x: u64 = 10; const y: f32 = x;)
  • f64.convert_u/i32 (const x: u32 = 10; const y: f64 = x;)
  • f64.convert_u/i64 (const x: u64 = 10; const y: f64 = x;)

Example

const x: u32 = 42;
const y: u32 = 0xffffffff;
const z: i32 = x < y; // should be 1

贡献者指南