ID:2591549
 
Not a bug
BYOND Version:513
Operating System:Windows 10 Pro 64-bit
Web Browser:Chrome 83.0.4103.116
Applies to:DM Language
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
Zero bitshifting a negative number results in 1.67772e+07 instead of the expected value

Numbered Steps to Reproduce Problem:
1. Zero-bitshift a negative number
2. The value will be 1.67772e+07

Code Snippet (if applicable) to Reproduce Problem:
world.log << (12.9 >> 0)
world.log << (-12.9 >> 0)


Expected Results:
12, -12

Actual Results:
12, 1.67772e+07

Does the problem occur:
Every time? Or how often? Every time
In other games? n/a
In other user accounts? n/a
On other computers? n/a

When does the problem NOT occur?
n/a

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Unsure.

Workarounds:
n/a
Interesting.

world.log << num2text(-12.9 << 0, 10)        // 0
world.log << num2text(-12.9 >> 0, 10) // 16777204
world.log << num2text(-12.9 & 0xFFFFFF, 10) // 16777204
world.log << num2text(-12.9 & 0x1FFFFFE, 10) // 16777204


16777204 is 2^24-12, the same bit pattern -12 should have in a 24-bit signed integer but interpreted as unsigned instead.


edit: changed last line from 0x1FFFFFF (rounding to 0x2000000) to 0x1FFFFFE (staying as 0x1FFFFFE) as it confused the results
I'm not sure why you think lopping off the fractional part is the expected behavior here.
The Ref does state that the operator only works on positive numbers.
Lummox JR resolved issue (Not a bug)
You're seeing undefined behavior per the reference.