开发者

Get Upper 4bits of a byte

开发者 https://www.devze.com 2023-03-15 16:52 出处:网络
I am trying to get the upper 4 bits of a Byte. That is my attempt so far: function Upper4B开发者_StackOverflowits(const X : Byte): Byte;

I am trying to get the upper 4 bits of a Byte.

That is my attempt so far:

function Upper4B开发者_StackOverflowits(const X : Byte): Byte;
type 
   BS = set of 0..7;
var 
   K : Byte; Q: BS;
begin
  Q := [];
  for K := 0 to 3 do {is it right? upper?}
    {what i need here?}
    Include(Q, {what i put here});

  Upper4Bits := Byte(Q)
end;

Thanks In Advance.


According to your comment to kotlinski's answer, you want result := (byte1 and $F0) or (byte3 and $0F).


Get Upper 4bits of a byte


How about Upper4Bits := X Shr 4;?

0

精彩评论

暂无评论...
验证码 换一张
取 消