Module binary

read and write (little endian) binary.

located in leef.binary.

reading binary inputs

read_single (function) read an IEEE 754 single precision (32-bit) floating point number
read_double (function) read an IEEE 754 double-precision (64-bit) floating point number
read_uint (function, int) read an unsigned integer of any given length
read_uint (function, int) read a signed integer of any given length

misc binary helpers

fround (number) "returns nearest 32-bit single precision float representation of a number" (or something)

expected function inputs

read_byte () read_byte is a param name which refers to a function which reads the next byte- returning a whole number between 0-255.
write_byte () write_byte is similar to read_byte, however it is given an input and expected to write it to the file.


reading binary inputs

read a binary inputs using a read_byte function.
read_single (function)
read an IEEE 754 single precision (32-bit) floating point number

Parameters:

read_double (function)
read an IEEE 754 double-precision (64-bit) floating point number

Parameters:

read_uint (function, int)
read an unsigned integer of any given length

Parameters:

  • function read_byte
  • int length in bytes of unsigned integer
read_uint (function, int)
read a signed integer of any given length

Parameters:

  • function read_byte
  • int length in bytes of integer

misc binary helpers

fround (number)
"returns nearest 32-bit single precision float representation of a number" (or something)

Parameters:

  • number

Returns:

    nearest 32-bit single precision float representation of a number

expected function inputs

functions will expect either a read_byte or write_byte function as inputs
read_byte ()

read_byte is a param name which refers to a function which reads the next byte- returning a whole number between 0-255.

function byte()
    left = left - 1
    return assert(file_handle:read(1):byte())
    --reads the next chracter, and converts it to a "numerical code" using string.byte()
    --it's important that this function moves forward in the file stream (as :read(1) does)
end

Returns:

    a bytecode (an int between 0 and 255.)
write_byte ()
write_byte is similar to read_byte, however it is given an input and expected to write it to the file. (example needed)
generated by LDoc 1.5.0 Last updated 2024-01-08 19:32:24