A tuple containing 4 bytes comprising a 4-byte integer. b1 is the least significant byte, b4 is the most significant byte. All functions operating on this are LSB first. The bytes are always unsigned, from 0 to 255.
WARNING: This library contains no safety bound checks to guarantee that these bytes stay in the 0-255 range. If these values go out of bounds, the behaviour is undefined. *
public function byte4.select(int pos) returns intSelects the n-th byte from these bytes, starting from 0 for the least significant byte and ending with 3 for the most significant byte. *
public function byte4.put(int pos, int value) returns byte4Replaces the byte in the n-th position with the provided one. *
public function byte4.toInt() returns intRe-assembles these bytes into an integer. *
public function int.toUnsigned() returns intClears the sign bit, which is a 31-bit mask: the result is always in [0, INT_MAX], so it is not the unsigned 32-bit reading of the integer. Examples: -1 -> INT_MAX, INT_MIN -> 0, positive integers are unchanged. *
public function int.byte1() returns intThe least significant byte, from 0 to 255. Matches bytes().b1, also for negative integers.
public function int.byte2() returns intThe second byte, from 0 to 255. Matches bytes().b2, also for negative integers.
public function int.byte3() returns intThe third byte, from 0 to 255. Matches bytes().b3, also for negative integers.
public function int.byte4(int isNegative) returns intpublic function int.bytes() returns byte4De-composes an integer into 4 unsigned bytes. *
public function string.fromBitString() returns intProduces a signed integer from the bitstring. Input string may contain whitespace for padding. *
public function int.toBitString() returns stringProduces a bitstring from this integer. Zero yields “0”, and negative values yield their full 32 bit two’s complement representation. *
public function int.not8() returns int8-bit NOT (~) NOTE: Assumes number is in the range [0, 255]
number.not8() equivalent to (~number) *
public function int.not32() returns int32-bit NOT (~)
number.not32() equivalent to (~number) *
public function int.and8(int other) returns int8-bit AND (&) NOTE: Assumes both operands are in the range [0, 255]
number.and8(other) equivalent to (number & other) *
public function int.and32(int other) returns int32-bit AND (&)
number.and32(other) equivalent to (number & other) *
public function int.or8(int other) returns int8-bit OR (|) NOTE: Assumes both operands are in the range [0, 255]
number.or8(other) equivalent to (number | other) *
public function int.or32(int other) returns int| 32-bit OR ( | ) |
number.or32(other) equivalent to (number | other) *
public function int.xor8(int other) returns int8-bit XOR (^) NOTE: Assumes both operands are in the range [0, 255]
number.xor8(other) equivalent to (number ^ other) *
public function int.xor32(int other) returns int32-bit XOR (^)
number.xor32(other) equivalent to (number ^ other) *
public function int.shiftl(int amount) returns int32-bit SHIFTL («)
number.shiftl(amount) equivalent to (number « amount) Bits shifted past bit 31 are discarded, so a shift of 32 yields 0. amount must be in [0, 32]; other values read outside the shift table. *
public function int.shiftr(int amount) returns int32-bit logical SHIFTR (»>)
number.shiftr(amount) equivalent to (number »> amount): the sign bit is shifted in as data rather than replicated, so negative inputs produce a positive result for any amount > 0.
amount must be in [0, 31] - one less than shiftl accepts. The shift table holds 2^32 as 0 after wrapping, so an amount of 32 divides by zero rather than returning 0. Guard the call if the amount is computed. *