isaacscript-common 5.1.1 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/functions/bitwise.lua +9 -6
- package/package.json +1 -1
package/functions/bitwise.lua
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
2
|
local __TS__ParseInt = ____lualib.__TS__ParseInt
|
|
3
|
-
local
|
|
3
|
+
local __TS__NumberToString = ____lualib.__TS__NumberToString
|
|
4
4
|
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
5
|
+
local __TS__ArrayUnshift = ____lualib.__TS__ArrayUnshift
|
|
5
6
|
local ____exports = {}
|
|
6
7
|
local ____flag = require("functions.flag")
|
|
7
8
|
local addFlag = ____flag.addFlag
|
|
@@ -27,11 +28,13 @@ end
|
|
|
27
28
|
-- any padding).
|
|
28
29
|
function ____exports.convertDecimalToBinary(self, number, minLength)
|
|
29
30
|
local bits = {}
|
|
30
|
-
local
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
local bitsString = __TS__NumberToString(number, 2)
|
|
32
|
+
for ____, bitString in __TS__Iterator(bitsString) do
|
|
33
|
+
local bit = tonumber(bitString)
|
|
34
|
+
if bit == nil then
|
|
35
|
+
error("Failed to convert the following number to binary: " .. tostring(number))
|
|
36
|
+
end
|
|
37
|
+
bits[#bits + 1] = bit
|
|
35
38
|
end
|
|
36
39
|
if minLength ~= nil then
|
|
37
40
|
while #bits < minLength do
|