Community

SCI Programming => SCI Syntax Help => Topic started by: gumby on August 01, 2021, 11:01:45 AM

Title: Numeric overflow
Post by: gumby 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  :-[