Depending on a variable 1-7, I am interested in ANDing a byte value to to get that number of bits.
Currently I'm doing this:
function getMaskedBits(num, Bit_location: Byte): Byte;
var
masks: array[1..7]of Byte=(127,63,31,15,7,3,1);
begin
Result:=num and masks[Bit_location];
end;
is there a better (or more efficient way of doing this?)
2
Contributors
2
Replies
1 Week
Discussion Span
3 Months Ago
Last Updated
14
Views
Related Article:May I ask you a question on Delphi?
is a solved Pascal and Delphi discussion thread by turbomen that has 4 replies and was last updated 8 months ago.