Quirk when doing integer Shl with >31 bits
Archives Forums/BlitzMax Bug Reports/Quirk when doing integer Shl with >31 bits
| ||
This is a rare one because trying to shift by that many bits is almost certainly a mistake. On Intel processors when shifting a 32-bit integer by nBits only the lowest five bits of nBits are used. This is the same as reducing nBits Mod 32. In the following test code all results should be the same because 18, 50, 82, 114 and 146 are congruent mod 32. The results are correct when nBits is a variable but wrong for numeric literals. Maybe they are being evaluated as if they were 64-bit integers, with the resulting values then being cast to 32 bits. Print Print 1 Shl 18 Print 1 Shl 50 Print 1 Shl 82 Print 1 Shl 114 Print 1 Shl 146 n50 = 50 n114 = 114 Print Print 1 Shl n50 Print 1 Shl n114 This is such an unusual situation that it may not be worth the effort to fix, unless it's really easy. |