Skip to content
This repository was archived by the owner on Oct 21, 2025. It is now read-only.

Commit facc08e

Browse files
authored
fix (#191)
1 parent 107c7b0 commit facc08e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/Data/Global.lua

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ end
9595

9696
-- NOTE: the LuaJIT bitwise operations we have are not 64-bit
9797
-- so we need to implement them ourselves. Lua uses 53-bit doubles.
98+
HIGH_MASK_53 = 0x1FFFFF
9899
function OR64(a, b)
99100
-- Split into high and low 32-bit parts
100101
local ah = math.floor(a / 0x100000000)
@@ -107,7 +108,7 @@ function OR64(a, b)
107108
local low = bit.bor(al, bl)
108109

109110
-- Combine the results
110-
return bit.band(high, 0x7FF) * 0x100000000 + low
111+
return bit.band(high, HIGH_MASK_53) * 0x100000000 + low
111112
end
112113

113114
function AND64(a, b)
@@ -122,7 +123,7 @@ function AND64(a, b)
122123
local low = bit.band(al, bl)
123124

124125
-- Combine the results
125-
return bit.band(high, 0x7FF) * 0x100000000 + low
126+
return bit.band(high, HIGH_MASK_53) * 0x100000000 + low
126127
end
127128

128129
function XOR64(a, b)
@@ -137,7 +138,7 @@ function XOR64(a, b)
137138
local low = bit.bxor(al, bl)
138139

139140
-- Combine the results
140-
return bit.band(high, 0x7FF) * 0x100000000 + low
141+
return bit.band(high, HIGH_MASK_53) * 0x100000000 + low
141142
end
142143

143144
function NOT64(a)
@@ -155,7 +156,16 @@ function NOT64(a)
155156

156157
-- Use bit operations to combine the results
157158
-- This avoids potential floating-point precision issues
158-
return bit.band(high, 0x7FF) * 0x100000000 + low
159+
return bit.band(high, HIGH_MASK_53) * 0x100000000 + low
160+
end
161+
162+
function strHex64(value)
163+
-- Split into high and low 32-bit parts
164+
local high = math.floor(value / 0x100000000)
165+
local low = value % 0x100000000
166+
167+
-- Stringify as two 8-digit hex values
168+
return string.format("0x%08X%08X", high, low)
159169
end
160170

161171
ModFlag = { }

0 commit comments

Comments
 (0)