GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bitwise &, |, ^, and ~ on Lua 5.3+ do not truncate operands or results to signed 32-bit integers · Issue #1732 · TypeScriptToLua/TypeScriptToLua

Bitwise &, |, ^, and ~ on Lua 5.3+ do not truncate operands or results to signed 32-bit integers #1732

New issue
Copy link
New issue
Copy link
Open
Open
Bitwise &, |, ^, and ~ on Lua 5.3+ do not truncate operands or results to signed 32-bit integers#1732
Copy link

Description

@trackoor
trackoor
opened on Nov 7, 2026
Issue body actions

In typescript-to-lua 1.37.1 targeting Lua 5.3 or 5.4, bitwise &, |, ^, and ~ emit raw Lua 64-bit integer operators without ToInt32 conversion. Values outside the signed 32-bit range are not wrapped to 32-bit signed integers, and non-integral floats throw a runtime error instead of truncating toward zero (breaking x | 0).

console.log(0x80000000 | 0);
console.log(4294967297 | 0);
console.log(-1 & 0xffffffff);
console.log(~0xffffffff);
console.log(0x80000000 ^ 0);
console.log(1.5 | 0);

Node prints -2147483648, 1, -1, 0, -2147483648, and 1, as required by ECMA-262 (ToInt32 on operands and signed 32-bit results).

When transpiled with luaTarget: "5.4" (or "5.3"), Lua prints 64-bit results and then fails on 1.5 | 0:

2147483648
4294967297
4294967295
-4294967296
2147483648
lua: main.lua:7: number has no integer representation

Credit: https://ucsbplse.github.io/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.