You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a small program using tonc that just displays the string resulting from sprintf(str, "should print \"-1\": %d\n", -1);. The resulting GBA file faithfully prints should print "-1": -1 on mGBA on mac, PizzaBoy on Android, and SkyEmu in browser; but for gba.js.org, it prints should print "-1": -4294967297.
-4294967297 is 0x100000001 in hex; I would expect 0xffffffff instead. If I change the format string from %d to %x, all emulators print 0xffffffff. To me this indicates that the affected code is in sprintf, but the bug is in the emulator as an identical sprintf version is compiled into the same .gba file that results in different behavior per emulator.
jackbonaguro
changed the title
Internal representation of -1 inconsistent with other emulators
Sprintf decimal formatting inconsistent with other emulators
Sep 4, 2024
I wrote a small program using tonc that just displays the string resulting from
sprintf(str, "should print \"-1\": %d\n", -1);
. The resulting GBA file faithfully printsshould print "-1": -1
on mGBA on mac, PizzaBoy on Android, and SkyEmu in browser; but for gba.js.org, it printsshould print "-1": -4294967297
.-4294967297 is 0x100000001 in hex; I would expect 0xffffffff instead. If I change the format string from
%d
to%x
, all emulators print 0xffffffff. To me this indicates that the affected code is in sprintf, but the bug is in the emulator as an identical sprintf version is compiled into the same .gba file that results in different behavior per emulator.Screenshots:
SkyEmu (web.skyemu.app):
GBA.JS.ORG:
main.c:
Attached .zip file includes sources and built .gba file. Depends on a working devkitPro toolchain to build from source.
gba-test.zip
The text was updated successfully, but these errors were encountered: