Seed7 - The extensible programming language
Seed7 FAQ Manual Screenshots Examples Libraries Algorithms Download Links
Libraries AES ARC4 Array ASN.1 Bigfile Bigint Bigrat Bin32 Bin64 Bitdata Bitmapfont Bitset Bitsetof Boolean Browser Bstring Bytedata Cards Category CC config Cgi Cgi dialog Char Charsets Cipher Clib_file Color CLI Commands Complex Console Crc32 Deflate DES Dialog Dir Draw Duration Echo Editline Enable_input Enable_io Enable_output Encoding Environment External_file File File system Float Font Forloop Ftp Getf Gethttp Gethttps Graph Graph_file Gzip Hash Hashsetof Hmac Html_ent Httpserv Idxarray Image Inflate Inflate file Inifile Integer Keybd Line Listener LZW Make Math Msgdigest Null_file Osfiles Picture utility Pixmap_file Pixmapfont PKCS #1 Poll Process Progs Propertyfile Rational Reference Ref_list Scanfile Scanstri Set Shell Smtp Sockbase Socket SQL base Stdio Strifile String Stritext Subrange Tar Text Time TLS/SSL Triple DES Unicode Utf16 Utf8 Vectorfont 3D Vector Window Wrinum X.509 Xmldom Xml_ent Zip
Libraries
Bitdata Source Code
 previous   up   next 

Constant Summary
array array integer
reverseBits
Array to reverse the bits of small numbers.

Function Summary
integer
getBitLsb (in string: stri, inout integer: bytePos, inout integer: bitPos)
Get one bit in LSB-First order from stri.
integer
getBitsLsb (in string: stri, inout integer: bytePos, inout integer: bitPos, in var integer: bitWidth)
Get bitWidth bits in LSB-First order from stri.
void
putBitLsb (inout string: stri, inout integer: bitPos, in integer: bit)
Append one bit in LSB-First order to stri.
void
putBitsLsb (inout string: stri, inout integer: bitPos, in var integer: bits, in var integer: bitWidth)
Append bitWidth bits in LSB-First order to stri.
integer
getBitMsb (in string: stri, inout integer: bytePos, inout integer: bitPos)
Get one bit in MSB-First order from stri.
integer
getBitsMsb (in string: stri, inout integer: bytePos, inout integer: bitPos, in var integer: bitWidth)
Get bitWidth bits in MSB-First order from stri.
void
putBitMsb (inout string: stri, inout integer: bitPos, in integer: bit)
Append one bit in MSB-First order to stri.
void
putBitsMsb (inout string: stri, inout integer: bitPos, in var integer: bits, in var integer: bitWidth)
Append bitWidth bits in MSB-First order to stri.
integer
getBitLsb (inout file: inFile, inout integer: bitPos)
Get one bit in LSB-First order from inFile.
integer
getBitsLsb (inout file: inFile, inout integer: bitPos, in var integer: bitWidth)
Get bitWidth bits in LSB-First order from inFile.

Constant Detail

reverseBits

const array array integer: reverseBits

Array to reverse the bits of small numbers. The first index is the number of bits to be reversed (between 2 and 9). The second index is the number for which the bits should be reversed.

reverseBits[2][2#10]      returns  2#1
reverseBits[4][2#1101]    returns  2#1011
reverseBits[6][2#110101]  returns  2#101011

Function Detail

getBitLsb

const func integer: getBitLsb (in string: stri, inout integer: bytePos, inout integer: bitPos)

Get one bit in LSB-First order from stri. The bit is read at the current byte and bit position. Afterwards byte and bit position are advanced by one bit. The read direction is from LSB (least significant bit) to MSB (most significant bit).

Parameters:
stri - String of bytes from which the bit is read.
bytePos - Current byte position in stri.
bitPos - Current bit position between 0 (=LSB) and 7 (=MSB).
Raises:
RANGE_ERROR - When the end of stri has been reached.

getBitsLsb

const func integer: getBitsLsb (in string: stri, inout integer: bytePos, inout integer: bitPos, in var integer: bitWidth)

Get bitWidth bits in LSB-First order from stri. The bits are read at the current byte and bit position. Afterwards byte and bit position are advanced by bitWidth bits. The read direction is from LSB (least significant bit) to MSB (most significant bit). When bits from the next byte(s) are read a byte order of little-endian is used.

stri := "\2#01101011;\2#1110;"; bytePos := 1; bitPos := 5;
#           011           10
#       lower bits    higher bits
#        of result     of result
getBitsLsb(stri, bytePos, bitPos, 5)  returns  2#10011 (bytePos=2, bitPos=2)
Parameters:
stri - String of bytes from which the bits are read.
bytePos - Current byte position in stri.
bitPos - Current bit position between 0 (=LSB) and 7 (=MSB).
bitWidth - Number of bits requested.
Raises:
RANGE_ERROR - When the end of stri has been reached.

putBitLsb

const proc: putBitLsb (inout string: stri, inout integer: bitPos, in integer: bit)

Append one bit in LSB-First order to stri. The bit is appended to stri at the current bit position. Afterwards the bit position is advanced by one bit. The append direction is from LSB (least significant bit) to MSB (most significant bit). If necessary stri is enlarged.

Parameters:
stri - String of bytes to which the bit is appended.
bitPos - Current bit position between 0 (=LSB) and 7 (=MSB).
bit - Bit to be appended to stri.

putBitsLsb

const proc: putBitsLsb (inout string: stri, inout integer: bitPos, in var integer: bits, in var integer: bitWidth)

Append bitWidth bits in LSB-First order to stri. The bits are appended to stri at the current bit position. Afterwards the bit position is advanced by bitWidth bits. The append direction is from LSB (least significant bit) to MSB (most significant bit). If necessary stri is enlarged with bytes in little-endian byte order.

stri := "\2#01011;"; bitPos := 5;
putBitsLsb(stri, bitPos, 2#10011, 5);
# Now holds:  stri = "\2#01101011;\2#10;"  and  bitPos = 2
#                        011         10
#                     appended    appended
#                    lower bits  higher bits
Parameters:
stri - String of bytes to which the bits are appended.
bitPos - Current bit position between 0 (=LSB) and 7 (=MSB).
bits - Bits to be appended to stri.
bitWidth - Number of bits to be appended (width of bits).

getBitMsb

const func integer: getBitMsb (in string: stri, inout integer: bytePos, inout integer: bitPos)

Get one bit in MSB-First order from stri. The bit is read at the current byte and bit position. Afterwards byte and bit position are advanced by one bit. The read direction is from MSB (most significant bit) to LSB (least significant bit).

Parameters:
stri - String of bytes from which the bit is read.
bytePos - Current byte position in stri.
bitPos - Current bit position between 0 (=MSB) and 7 (=LSB).
Raises:
RANGE_ERROR - When the end of stri has been reached.

getBitsMsb

const func integer: getBitsMsb (in string: stri, inout integer: bytePos, inout integer: bitPos, in var integer: bitWidth)

Get bitWidth bits in MSB-First order from stri. The bits are read at the current byte and bit position. Afterwards byte and bit position are advanced by bitWidth bits. The read direction is from MSB (most significant bit) to LSB (least significant bit). When bits from the next byte(s) are read a byte order of big-endian is used.

stri := "\2#01011100;\2#11010110;"; bytePos := 1; bitPos := 5;
#                100    11
#         higher bits  lower bits
#          of result    of result
getBitsMsb(stri, bytePos, bitPos, 5)  returns  2#10011 (bytePos=2, bitPos=2)
Parameters:
stri - String of bytes from which the bits are read.
bytePos - Current byte position in stri.
bitPos - Current bit position between 0 (=MSB) and 7 (=LSB).
bitWidth - Number of bits requested.
Raises:
RANGE_ERROR - When the end of stri has been reached.

putBitMsb

const proc: putBitMsb (inout string: stri, inout integer: bitPos, in integer: bit)

Append one bit in MSB-First order to stri. The bit is appended to stri at the current bit position. Afterwards the bit position is advanced by one bit. The append direction is from MSB (most significant bit) to LSB (least significant bit). If necessary stri is enlarged.

Parameters:
stri - String of bytes to which the bit is appended.
bitPos - Current bit position between 0 (=MSB) and 7 (=LSB).
bit - Bit to be appended to stri.

putBitsMsb

const proc: putBitsMsb (inout string: stri, inout integer: bitPos, in var integer: bits, in var integer: bitWidth)

Append bitWidth bits in MSB-First order to stri. The bits are appended to stri at the current bit position. Afterwards the bit position is advanced by bitWidth bits. The append direction is from MSB (most significant bit) to LSB (least significant bit). If necessary stri is enlarged with bytes in big-endian byte order.

stri := "\2#01011000;";
putBitsMsb(stri, bitPos, 2#10011, 5);
# Now holds  stri = "\2#01011100;\2#11000000;"  and  bitPos = 2
#                            100    11
#                        appended  appended
#                     higher bits  lower bits
Parameters:
stri - String of bytes to which the bits are appended.
bitPos - Current bit position between 0 (=MSB) and 7 (=LSB).
bits - Bits to be appended to stri.
bitWidth - Number of bits to be appended (width of bits).

getBitLsb

const func integer: getBitLsb (inout file: inFile, inout integer: bitPos)

Get one bit in LSB-First order from inFile. The bit is read at the current byte and bit position. Afterwards byte and bit position are advanced by one bit. The read direction is from LSB (least significant bit) to MSB (most significant bit).

Parameters:
inFile - File of bytes from which the bit is read.
bitPos - Current bit position between 0 and 8. 0 = LSB, 7 = MSB, 8 = A bitPos of 0 (=LSB) in the next byte.
Raises:
FILE_ERROR - When reading from inFile fails.

getBitsLsb

const func integer: getBitsLsb (inout file: inFile, inout integer: bitPos, in var integer: bitWidth)

Get bitWidth bits in LSB-First order from inFile. The bits are read at the current byte and bit position. Afterwards byte and bit position are advanced by bitWidth bits. The read direction is from LSB (least significant bit) to MSB (most significant bit). When bits from the next byte(s) are read a byte order of little-endian is used.

Parameters:
inFile - File of bytes from which the bits are read.
bitPos - Current bit position between 0 and 8. 0 = LSB, 7 = MSB, 8 = A bitPos of 0 (=LSB) in the next byte.
bitWidth - Number of bits requested.
Raises:
FILE_ERROR - When reading from inFile fails.


 previous   up   next