Title: [fork-ffi] integers: rem — PureScript/JS `rem` is the TRUNCATED remainder (result takes the sign… · Issue #88 · purescript-lua/purescript-lua · GitHub
Open Graph Title: [fork-ffi] integers: rem — PureScript/JS `rem` is the TRUNCATED remainder (result takes the sign… · Issue #88 · purescript-lua/purescript-lua
X Title: [fork-ffi] integers: rem — PureScript/JS `rem` is the TRUNCATED remainder (result takes the sign… · Issue #88 · purescript-lua/purescript-lua
Description: Package: purescript-lua-integers File: src/Data/Int.lua Function: rem Class: semantics Severity: high PureScript/JS rem is the TRUNCATED remainder (result takes the sign of the dividend): JS does x % y, and in JS % truncates toward zero....
Open Graph Description: Package: purescript-lua-integers File: src/Data/Int.lua Function: rem Class: semantics Severity: high PureScript/JS rem is the TRUNCATED remainder (result takes the sign of the dividend): JS does x...
X Description: Package: purescript-lua-integers File: src/Data/Int.lua Function: rem Class: semantics Severity: high PureScript/JS rem is the TRUNCATED remainder (result takes the sign of the dividend): JS does x...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/88
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[fork-ffi] integers: rem — PureScript/JS `rem` is the TRUNCATED remainder (result takes the sign…","articleBody":"**Package:** purescript-lua-integers \n**File:** `src/Data/Int.lua` \n**Function:** `rem` \n**Class:** semantics **Severity:** high\n\nPureScript/JS `rem` is the TRUNCATED remainder (result takes the sign of the dividend): JS does `x % y`, and in JS `%` truncates toward zero. Lua's `%` operator is the FLOORED modulo (result takes the sign of the divisor). They differ for mixed-sign operands: `rem (-2) 3` is -2 in PureScript but 1 in Lua; `rem 2 (-3)` is 2 in PureScript but -1 in Lua. This breaks both the documented examples in Data.Int.purs (rem (-2) 3 == (-2), rem 2 (-3) == 2) and the package's quot/rem law test `q*b + r == a` for `go (-2) 3` and `go 2 (-3)` (Test/Data/Int.purs lines 170-171): with the current rem, 0*3 + 1 = 1 != -2.\n\n**Current (Lua):**\n```lua\nrem = (function(x) return function(y) return x % y end end),\n```\n\n**Expected:** Truncated remainder with the sign of the dividend: rem (-2) 3 == -2, rem 2 (-3) == 2, and q*b + r == a where q = quot x y.\n\n**Proposed fix:**\n```lua\nrem = (function(x) return function(y)\n if y == 0 then return 0 end\n local q = math.modf(x / y) -- truncate toward zero, matching quot\n return x - q * y\nend end),\n```\n\n_Found by the FFI audit; reproduced under Lua 5.1._","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-06-15T11:24:08Z","url":"https://github.com/purescript-lua/purescript-lua/issues/88"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:895d3996-8266-f287-599b-34cbfe83a1fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C936:1DB641:987C38:C66861:6B00DFB5 |
| html-safe-nonce | bfe4043ff09855eebcd37f193269018672a68ec508663235f464917ab106d7c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTM2OjFEQjY0MTo5ODdDMzg6QzY2ODYxOjZCMDBERkI1IiwidmlzaXRvcl9pZCI6IjY4MDU4MjA4NTU2Njc0NDk3ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 090f21328570ac8f4b434e35870f25aad0507957ff10f07a4fe8aa777e08fcbd |
| hovercard-subject-tag | issue:4664608222 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/purescript-lua/purescript-lua/88/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8534232fae12939ad0c343c48b5503ad3bec9fa7177ae31750088a7228e397fb/purescript-lua/purescript-lua/issues/88 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8534232fae12939ad0c343c48b5503ad3bec9fa7177ae31750088a7228e397fb/purescript-lua/purescript-lua/issues/88 |
| og:image:alt | Package: purescript-lua-integers File: src/Data/Int.lua Function: rem Class: semantics Severity: high PureScript/JS rem is the TRUNCATED remainder (result takes the sign of the dividend): JS does x... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Unisay |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/purescript-lua/purescript-lua git https://github.com/purescript-lua/purescript-lua.git |
| octolytics-dimension-user_id | 131581790 |
| octolytics-dimension-user_login | purescript-lua |
| octolytics-dimension-repository_id | 587200487 |
| octolytics-dimension-repository_nwo | purescript-lua/purescript-lua |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 587200487 |
| octolytics-dimension-repository_network_root_nwo | purescript-lua/purescript-lua |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width