Page MenuHomeFeedback Tracker

Bit shifting produces unexpected values
Assigned, NormalPublic

Description

As title says. Example:

int a = 0xb3000000 >> 24;  // result: 0xffffffb3, should be 0xb3

Can be worked-around by masking after shift

int b = a & 0xff;  // 0xb3

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Modding

Event Timeline

lava76 created this task.Dec 4 2023, 7:52 PM
Geez changed the task status from New to Assigned.Dec 5 2023, 10:26 AM

Why is this a bug ? This is normal behavior for negative numbers. What you mean is >>>, which does not care about the sign of the number

Changing this will 100% break more mods than it will fix. Either introduce a >>> for it or don't change it

lava76 added a comment.EditedJan 18 2024, 1:15 PM

Not the behavior in C or C++, which is what I'm going off of. But I guess in C or C++ the compiler actually recognizes the initial value as an uint, so non-negative.

This can probably be closed as not a bug though because EnfScript doesn't have an uint type.