Hi Ross This one shouldn't be too hard:
function BitValue(Value,Bit: Byte): Boolean; begin Result := (Value and (1 shl Bit))<>0; end; Be aware, that there is no error checking if Bit is in range 0..7! If Value is of type integer instead of byte, the allowed range would be 0..31. HTH Armin > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Ross Levis > Sent: Saturday, January 14, 2006 11:19 AM > To: Delphi Discussion List > Subject: bits > > Hi. > > I then need a function that checks 1 bit of a byte value and > returns true or false representing 1 or 0. > > function BitValue(Value,Bit: Byte): Boolean; begin > Result := ??? > end; > > Bit has the range 0 to 7 or 1 to 8. > > eg. BitValue(255,4) = True; > > I've not done much binary manipulation before but I believe > it requires AND, OR, or XOR, but I'm not sure how to do it. Anyone? > > Thanks, > Ross. > > _______________________________________________ > Delphi mailing list -> [email protected] > http://www.elists.org/mailman/listinfo/delphi > _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

