Author Topic: Numeric overflow  (Read 1029 times)

0 Members and 1 Guest are viewing this topic.

Offline gumby

Numeric overflow
« on: August 01, 2021, 11:01:45 AM »
Here's a bit of code that caused downstream problems in my game resulting in OOPS messages.  My use case was debugging the results from checking flags and got nailed when the gFlags index was 16.

Code: [Select]
    (DebugPrint "Flag value = %d" (Btest MY_FLAG))

Simplified, you can get the same result with:
Code: [Select]
    (DebugPrint "Flag value = %d" $8000)

It returns "Print this = -4294934528", which is an overflow for a 16 bit integer - I should have used %x instead  :-[


In the Great Underground Empire (Zork port in development)
Winter Break 2012 Rope Prop Competition


SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.302 seconds with 23 queries.