Manipulating bit values
- Last Updated: January 17, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
Manipulating bit values
You can copy bit values up to the size of an ABL INTEGER from
one INTEGER value to another. The statement to
copy bit values to an INTEGER variable, PUT-BITS,
has the following syntax:
Syntax
|
This statement interprets an integer (integer-expression)
as the sequence of bits representing the binary value of integer-expression.
For example, if the value of integer-expression is
22, the bit sequence is 10110. The statement interprets the INTEGER variable, destination,
as a sequence of bits and writes the sequence of bits from integer-expression into destination,
starting at the specified bit position (start-position).
The bit position in destination is counted from
the low-order bit, where the first bit is bit one (1). If the value
of integer-expression is too large to store in
the specified number of bits, ABL stores the low-order count bits
of integer-expression in the specified count bits
within destination.
The function to return some number of bits from an INTEGER variable, GET-BITS,
has the following syntax:
Syntax
|
This function returns the INTEGER that represents the
value of the number of bits specified by count starting at
the specified low-order bit position (start-position) within
the INTEGER variable specified by source.
Thus, you can store bit values in MEMPTR variables and
return bit values from MEMPTR variables by using
the PUT-LONG statement and GET-LONG function
to store and return the corresponding INTEGER expression
that contains the bit pattern.