-> How do can I read the individual bits that are inside a byte?
Use the AND operator. For example, if B% contains a one-byte number,
then the following little program will tell you whether each of the
eight bits contains a 1 or a 0.
FOR X% = 0 TO 7
PRINT "Bit"; X%; " contains a ";
IF (B% AND 2^X%) > 0 THEN
PRINT "1"
ELSE
PRINT "0"
END IF
NEXT X%
It's the line with the AND in it that does the trick. Read up on that
operator to figure out how it works.
Incidentally, the brackets in that line are essential. AND is evaluated
*after* ">" if brackets are not used to force the opposite order.
dow
--- PCBoard (R) v15.3 (OS/2) 5
---------------
* Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)
|