[ZScript] uints are treated as signed when bit shifting

Bugs that have been investigated and resolved somehow.

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.
Post Reply
Guest

[ZScript] uints are treated as signed when bit shifting

Post by Guest »

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?
User avatar
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

Post by phantombeta »

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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
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

Post by Graf Zahl »

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.
Post Reply

Return to “Closed Bugs [GZDoom]”