The number of bit places in a shift operation is ANDed by the width of the type
when it is in a register, so (1 << c), when c is 32, is actually 1, and not 0.
Fix the calculation of MaxValue by using SignFlag | (SignFlag - 1) instead.
svn path=/branches/ntvdm/; revision=60912
{
ULONG Result;
ULONG SignFlag = 1 << (Bits - 1);
{
ULONG Result;
ULONG SignFlag = 1 << (Bits - 1);
- ULONG MaxValue = (1 << Bits) - 1;
+ ULONG MaxValue = (SignFlag - 1) | SignFlag;
/* Make sure the values don't exceed the maximum for their size */
FirstValue &= MaxValue;
/* Make sure the values don't exceed the maximum for their size */
FirstValue &= MaxValue;