Titan



bitstring


The keyword bitstring denotes a basic string type whose distinguished values are the ordered sequences of zero, one or more bits.

Related keywords:


bitstring


Example 1:

const bitstring c_bitfolyam := '01001'B;

The constant defined is called c_bitfolyam and has the binary value 01001.


Example 2:

const bitstring c_whole := int2bit (112,8);

The constant called c_whole will contain the string 01110000 because the converted integer number (112 -> 1110000) must be coded on 8 bits and therefore padded with a leading zero.


Example 3:

const boolean c_vrai := ( c_bitfolyam != c_whole );

The constant c_vrai will have the value true, because two bit strings are not equal. The parentheses are optional.


Example 4:

const bitstring c_stick := c_bitfolyam & c_whole;

The constant c_stick will have the binary value 0100101110000.


Example 5:

const bitstring c_jediny := c_bitfolyam[1];

The constant called c_jediny will have the binary value 1.


Example 6:

const bitstring c_inget := ''B;

The constant called c_inget will be an empty string.


Example 7a:

const hexstring c_ganz := bit2hex ('111010111'B);

The constant called c_ganz will have the hexadecimal value 1D7. The bit string is divided in groups of four starting from the right and converted to hexadecimal digits. When the last group has less than four bits it will be padded with leading zeros


Example 7b:

const integer c_samostatny := bit2int ('1111111'B);

The constant called c_samostatny will have the integer value 127. The result will be always positive.


Example 7c:

const octetstring c_tre := bit2oct ('101001011010'B);

The constant called c_tre will have the value '0A5A'O .


Example 7d:

const charstring c_bokstaever := bit2str ('101001011010'B);

The constant called c_bokstaever will contain the string 101001011010 because the resulting character string has the same length as the bit string and contains only the characters '0' and '1'.


Example 7e:

const integer c_longeur := lengthof ('01001011010'B);

The constant called c_longeur will have the value 11 corresponding to the number of bits in the string .


Example 8:

var bitstring c_zabradli ('1010'B,'11'B,'011'B );

The variable called c_zabradli may assume the binary values 1010, 11, 011 only.


Example 9

const bitstring c_bithinta := '100001'B @> 2;

The constant called c_bithinta will hold the value '011000'B (the left operand rotated by two bits). 


Example 10:

const bitstring c_slippery := '111001'B << 2;

The constant called c_slippery will hold the value ''100100'B (the left operand shifted by two bits).



BNF definition of bitstring
BNF definition of bitstring value