Author Topic: Numeric overflow  (Read 1711 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 "Flag value = -4294934528", which is an overflow for a 16 bit integer - I should have used %x instead  :-[
« Last Edit: January 14, 2022, 08:15:54 PM by gumby »

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

SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.036 seconds with 23 queries.