Skip to content
CrocBlanc edited this page Sep 1, 2025 · 2 revisions

Binary

How to load

see import

local bin = dofile("binary.lua")
OR
local bin = import("https://raw.githubusercontent.com/CrocBlancYT/computer-craft-libraries/refs/heads/main/src/binary.lua")

Functions

new

local b = bin.new{true, false, ...}

fromNumber

local b = bin.fromNumber(128)
OR
local b = bin.fromNumber(0x80)

fromCharacter

local b = bin.fromCharacter("z")

Binary object

Functions

shift

local div2 = b:shift(-1)

invert

local not_b = b:invert()

toCharacter

local char = b:toCharacter()

toNumber

local number = b:toNumber()

toSave

local save = b:toSave()
-- {__type == "binary", [i] = b[i]}

+ - / *

local add = b1 + b2
local sub = b1 - b2
local b1_and_b2 = b1 * b2
local b1_xor_b2 = b1 / b2

Structure

{[1] = true | false ..}

Clone this wiki locally