Integer overflow: Difference between revisions

Content deleted Content added
Examples: Wrong units
Line 130:
In the arcade game ''[[Donkey Kong (arcade game)|Donkey Kong]]'', it is impossible to advance past level 22 due to an integer overflow in its time/bonus. The game calculates the time/bonus by taking the level number a user is on, multiplying it by 10, and adding 40. When they reach level 22, the time/bonus number is 260, which is too large for its 8-bit 256 value register, so it overflows to a value of 4 – too short to finish the level. In ''[[Donkey Kong Jr. Math]]'', when trying to calculate a number over 10,000, it shows only the first 4 digits. Overflow is the cause of the famous [[kill screen|"split-screen" level]] in ''[[Pac-Man]]''.<ref>{{cite web |url=http://home.comcast.net/~jpittman2/pacman/pacmandossier.html |title=The Pac-Man Dossier |last=Pittman |first=Jamey}}</ref> Such a bug also caused the ''Far Lands'' in ''[[Minecraft]]'' Java Edition which existed from the Infdev development period to Beta 1.7.3; it was later fixed in Beta 1.8. The same bug also existed in ''Minecraft'' Bedrock Edition but has since been fixed.<ref>{{cite web |url=https://minecraft.wiki/w/Far_Lands |title=Far Lands |website=Minecraft Wiki |access-date=24 September 2023 |language=en}}</ref>{{unreliable source|date=October 2024}}
 
In the [[Super Nintendo Entertainment System]] (SNES) game [[Lamborghini American Challenge]], the player can cause their amount of money to drop below $0 during a race by being fined over the limit of remaining money after paying the fee for a race, which glitches the integer and grants the player $65,535,000 more than it would have had after going negative.<ref>Archived at [https://ghostarchive.org/varchive/youtube/20211205/aNQdQPi0xMo Ghostarchive]{{cbignore}} and the [https://web.archive.org/web/20190726012137/https://www.youtube.com/watch?v=aNQdQPi0xMo&t=17m55s Wayback Machine]{{cbignore}}: {{cite web |url=https://www.youtube.com/watch?v=aNQdQPi0xMo&t=17m55s |title=Lamborghini American Challenge SPEEDRUN (13:24) |website=[[YouTube]]|date=14 March 2019 }}{{cbignore}}</ref>[[File:Error message due to an integer signedness bug in the stack setup code of MASM 1.00.gif|thumb|An integer signedness bug in the stack setup code emitted by the [[Pascal (programming language)|Pascal]] compiler prevented IBM–[[Microsoft Macro Assembler]] (MASM) version 1.00, a [[DOS]] program from 1981, and many other programs compiled with the same compiler, to run under some configurations with more than 512 KBKiB of memory.]]
 
IBM–[[Microsoft Macro Assembler]] (MASM) version 1.00, and likely all other programs built by the same [[Pascal (programming language)|Pascal]] compiler, had an integer overflow and signedness error in the stack setup code, which prevented them from running on newer [[DOS]] machines or emulators under some common configurations with more than 512 KB&nbsp;KiB of memory. The program either hangs or displays an error message and exits to DOS.<ref>{{cite web |last=Lenclud |first=Christophe |url=https://slions.net/threads/debugging-the-ibm-personal-computer-macro-assembler-masm-version-1-00.33/ |title=Debugging IBM MACRO Assembler Version 1.00|date=21 April 2017 }}</ref>
 
In August 2016, a [[casino]] machine at [[Resorts World]] casino printed a prize ticket of $42,949,672.76 as a result of an overflow bug. The casino refused to pay this amount, calling it a malfunction, using in their defense that the machine clearly stated that the maximum payout was $10,000, so any prize exceeding that had to be the result of a programming bug. The [[New York State Gaming Commission]] ruled in favor of the casino.<ref>{{cite web |last=Kravets |first=David |date=June 15, 2017 |url=https://arstechnica.com/tech-policy/2017/06/sorry-maam-you-didnt-win-43m-there-was-a-slot-machine-malfunction |title=Sorry ma'am you didn't win $43M – there was a slot machine 'malfunction' |website=Ars Technica}}</ref>