April 2nd Monday (四月 二日 月曜日)
来源:互联网 发布:干部网络培训工作总结 编辑:程序博客网 时间:2024/04/29 03:03
Today I began to read the source of LZ77. However, I almost met a difficult at once. There is
a function which is used to copy some bits from a byte to another byte.
I had a look at this function. There are two steps to set bits. Firstly, it set all bits "1"
needed. Secondly, it set all bits "0" needed.
void CopyBitsInAByte(BYTE* memDest, int nDestPos,
BYTE* memSrc, int nSrcPos, int nBits)
{
BYTE b1, b2;
b1 = *memSrc;
b1 <<= nSrcPos; b1 >>= 8 - nBits; // clearn bits except for needs
b1 <<= 8 - nBits - nDestPos; // adjust the correct position
*memDest |= b1; // set all 1 bits.
b2 = 0xff; b2 <<= 8 - nDestPos; // fill 1 into bits except for needs
b1 |= b2;
b2 = 0xff; b2 >>= nDestPos + nBits;
b1 |= b2;
*memDest &= b1; // set all 0 bits.
}
The above function is not complicated. But it is not easy to understand. Firstly, it clearn
all bits except for bits segment need copying. From "or" operating, those bits 0 was set. Other
bits keep its original content. This time, the "b1" is alike "0...0XXX0..0". At second step, the
"b1" must be set style like "1..1XXX1..1". This time, by "and" operating all bits 1 set and other
bits are not modified.
- April 2nd Monday (四月 二日 月曜日)
- 2008 April 2nd Wednesday (四月 二日 水曜日)
- April 2nd Tuesday (四月 二日 木曜日)
- 2008 April 21th Monday (四月 二十一日 月曜日)
- 2008 April 21th Monday (四月 二十一日 月曜日)
- 2008 April 28th Monday (四月 二十八日 月曜日)
- 2008 April 14th Monday (四月 十四日 月曜日)
- April 27th Monday (四月 二十七日 月曜日)
- February 2nd Monday 2009 (二月 二日 月曜日)
- 2009 March 2nd Monday (三月 二日 月曜日)
- April 13th Monday (四月 十三日 月曜日)
- April 20th Monday (四月 二十日 月曜日)
- 2008 April 7th Monday (四月 七日 月曜日)
- April 21th Tuesday (四月 二十一日 火曜日)
- April 24th Friday (四月 二十四日 金曜日)
- April 28th Tuesday (四月 二十八日 火曜日)
- Aprial 30th Monday (四月 三十日 月曜日)
- November 2nd Monday
- dom,jdom,xml
- 设计模式之bridge(桥)模式
- March 27th Tuesday (三月 二十七日 火曜日)
- March 28th Wednesday (三月 二十八日 水曜日)
- March 29th Thursday (三月 二十九日 木曜日)
- April 2nd Monday (四月 二日 月曜日)
- 英文简历
- April 3th Tuesday (四月 三日 火曜日)
- April 4th Wednesday (四月 四日 水曜日)
- 购买:《假如我能行走三天》 [张云成、2003年中国青年年度人物]
- April 5th Thursday (四月 五日 木曜日)
- April 6th Friday (四月 六日 金曜日)
- Java: RMI调用实例
- Aprial 9th Monday (四月 九日 月曜日)