Re: A89: Filling a Byte in C
[Prev][Next][Index][Thread]
Re: A89: Filling a Byte in C
>
> Well, it becomes 0 if you're masking the value to 8 bits...
>
Since the function GetByteMask() return a byte, that is what will happen...
Btw, I'm wondering how a byte rotation could be implemented in C. I would
think of the following functions, is there a better way ?
byte RotateByteLeft(byte number, int rotate)
{
int tmp = number << rotate;
return tmp | (tmp>>8);
}
byte RotateByteRight(byte number, int rotate)
{
int tmp = number << (8 - rotate);
return tmp | (tmp>>8);
}
Follow-Ups:
References: