function TestBit(const Value: Byte; const Bit: TBitRange): Boolean; begin Result := (Value and (1 shl (Bit mod BitsPerByte))) <> 0; end;
This code is from the JclLogic unit in Project Jedi JCL http://delphi-jedi.org/ -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ross Levis Sent: Saturday, January 14, 2006 5: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

