Test code:
uint x = 0xFFFFFFFF;
Console.printf("%08x", x >> 1);
Expected result: 7fffffff
Actual result: ffffffff
This is the result you'd expect from "(int32_t)0xFFFFFFFF >> 1". Why are uints being treated like regular ints for bit shifts?
[ZScript] uints are treated as signed when bit shifting
Moderator: GZDoom Developers
Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
- phantombeta
- Posts: 2089
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: [ZScript] uints are treated as signed when bit shifting
Likely because uints and int sizes other than 32-bit are quite buggy. Do keep in mind that there's an unsigned right shift operator, ">>>", though.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49071
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: [ZScript] uints are treated as signed when bit shifting
Fixed, but for obvious reasons this needs to be version protected so it will only be done correctly if ZScript version is 3.7 or higher.