Follow TV Tropes

Following

Overflow Error

Go To

https://static.tvtropes.org/pmwiki/pub/images/cant_sleep.png

In older electronics, 8 bits was the standard — strings of 0 and 1 were divided into sections of eight each, and it was seen as sufficient to get every letter and number across. It was an effective, compact way to store data, which is why it was largely used until the mid-1990s. The problem is, it also got the short end of the stick in Powers of Two Minus One: since binary works by an "on and off" system, there was a maximum value — 11111111, equal to FF in hexadecimal or 255 in base 10. Any commands to increase the value past this trigger the "next place value" protocol, which changes all 1s to 0s and turns the nearest 0 on the left into a 1. The problem is, there is no nearest 0 on the left, so the value rolls back to 00000000.

This can also work the other way around, which is called underflow — if a value attempts to decrease past 00000000, it will go "down" to 11111111, which can lead to some pretty strange variables.

Note that the limit does not strictly apply to 8-Bit systems and thus can be higher than 255, but occurrences of that sort are the most famous and most common due to the comparatively low cap. While mostly obsolete because of technology improvements, these types of errors still remain famous because they were known to cause some pretty hilarious crashes or Ascended Glitches.

This is a programming-specific relative of Readings Blew Up the Scale. In older video games, a Kill Screen or Minus World is often a result of this, when trying to read data for level "257" causes a Reality-Breaking Paradox or Logic Bomb. Compare Crosses the Line Twice when a situation is so horrible that, whether intentionally or not, it becomes hilarious.


Video Game Examples:

    open/close all folders 

    4X Games 
  • Civilization: A longstanding Urban Legend of Zelda argued that Mahatma Gandhi, the in-game leader of the India civilization, had an AI aggression level of 1, but when a civ adopted democracy and thereby reduced its aggression two steps, it would cause the 8-bit variable to wrap back around to 255 and make him insanely aggressive. The bug never actually existed according to series creator Sid Meier: his studio in fact anticipated the problem and coded aggression to never go below 1. India is somewhat more likely to invent nuclear weapons earlier than other countries, but that's actually a result of its AI being coded to prioritize scientific advancement. The memetic error was in fact made up by an Internet Troll on This Very Wiki, irritated that AI Gandhi had nuked him (which is still pretty funny considering Gandhi's real-world religiously motivated pacifism), supported by screenshots of the game's Mad Libs Dialogue.
  • Stellaris: An overflow error in some versions allows leaders to become immortal. As a leader ages, their chance of dying of old age increases until they reach their maximum lifespan, at which point their chance of dying from old age is 100%. Playing with policies to extend and then reduce the lifespan can create a leader whose chance of dying is greater than 100%. A leader who is about 24 years older than their maximum lifespan causes an overflow where their chance of dying resets from 100% to 0%.

    Action Games 
  • Atari's Battlezone (1980) started the player out with slower, boxy tanks to shoot, until the player had blasted five of them, then the game threw quicker, sleeker tanks at the player. That is, up until the player had 255 tanks killed; thereafter, the register overflowed to -1, an error code. The game however simply interpreted this as "player has not yet killed enough slow tanks" and thereafter fielded the older, slower boxy tanks. This typically happens around the 80000 to 90000 point mark.
  • The famous Kill Screen in Pac-Man was known to be caused due to the levels being stored in an 8 bit byte, and since the byte rolls over to zero, the game attempts to proceed to level 256, and renders more than half of the maze as a glitched array of tiles— the game keeps track of the level number by the fruit in the bottom right corner, and there's always meant to be only one. Similar glitches also exist in Galaga (which varies depending on what rank you have it set at) and Dig Dug (which causes a level that instantly kills you because an enemy spawns in the same space as the player).
  • Similarly, the kill screen in Donkey Kong is caused by a glitch in the algorithm that determines the level timer. On Level 22, the timer is set so high that it overflows and ends up being set at just 4 seconds, making the level impossible to complete.

    Adventure Games 
  • In some releases of Sweevo's World it was possible to lose two lives when you only had one left - for example, by being at minimum energy on your last life, and walking under a weight to touch an enemy. The enemy would kill you, then the dropping weight would kill you again; this would cause the lives counter to wrap round to 255.
  • The Legend of Zelda: Oracle Games have a cap of 24 heart containers, which can be reached in normal gameplay. In a linked game it's possible to unlock an additional heart container, but this causes an error that subtracts one heart container from Link instead: he ends up with a max of 23.
  • The Legend of Zelda: Skyward Sword has a minigame called Clean Cut where you cut a bamboo stalk as many times as you can. Getting 65 cuts resets the counter to 1.

    Card Games 
  • The Elder Scrolls: Legends: Although players won't reach a fraction of the maximum health or creature power in normal gameplay, intrepid players sought to experiment with the maximum amount. They confirmed that it was the integer limit of 2,147,483,647, and that going over this causes the number to go negative.
  • Hearthstone also has a integer limit of 2,147,483,647. The easiest way to reach it are cards like Divine Spirit and Linecracker, which have effects that multiply an attribute, and some way to infinitely recycle them. It's not something you can just casually do, but there have been challenge combo decks that hit that absurd number.

    Fighting Games 
  • In-Universe in Slap City's story mode: A cop attempts to write up Business Casual Man, only for his offenses to roll over to zero in the police database.

    Idle Games 
  • In Trimps, the developer was forced to cap the level number at 810 and add a parallel advancement (Universe 2) because making the game work with the numbers generated would have required rewriting the code in a different system.

    Platform Games 
  • Ratchet & Clank:
    • While most games cap how many Bolts you can hold, the PlayStation 2 ones didn't, leading to this error. Famously, a fan by the name of RSmit spent three and a half years doing this in the second game, Going Commando (saying that it was "too easy" to do it in the third and fourth games), in what he called the Quest for the Max. He eventually succeeded in 2007, and as a result flipped the number to approximately -2 billion Bolts... meaning he couldn't afford the Tractor Beam gadget to progress past the second level in his next Challenge Mode run.Why it happened
    • It's been observed in at least Going Commando that it's possible to complete Challenge Mode 255 times. If you do so the next Challenge Mode is in a state dubbed "New Game +0", where Ratchet retains all his weapons and gadgets as normal, but the enemies return to the stats they'd have on an initial playthrough.
  • Sonic the Hedgehog:
    • A Game-Breaking Bug in Sonic the Hedgehog causes the final boss to be unbeatable if you hit Dr. Eggman while his HP's 0. His programming doesn't check to see if his HP's already at 0 when you're hitting him, thus giving him 255 HP, which can't be depleted within the 10 minute time limit the game imposes on each level.
    • The 16-bit versions of Sonic 1 and Sonic the Hedgehog 2 feature a bug in which your character can lose two lives at once if they take damage while drowning. If you're on your last life, this causes your total number of lives to underflow, giving you 255 lives. This is such an absurdly high number that the game can't even display it correctly - the lives counter only has two digits, so numbers above 99 appear garbled.
    • The mainline 16-bit games have a bug known as the "level wrap" glitch, which comes from being unable to put the player's X-axis as a negative number. So if the player goes further left than the leftmost pixel of the stage, their X-axis instead becomes a very large number, and the player is suddenly teleported as far to the right as they can go. This normally puts them at the very end of the stage, where they complete the stage instantly if there's no boss, or fight said boss if there is one.
  • Super Mario Bros. stored the number of lives as a signed byte (ranging from -128 to 127). So Mario can safely have 127 lives, but if he has more than that and then dies, it's an instant game over. This inadvertently functions as a punishment for stockpiling lives with the Infinite 1-Ups trick, since having that many lives isn't likely to occur in the average playthrough.

    Roguelike 
  • Noita:
    • The Repelling Cape perk increases the speed at which stains fade on the player, and additional copies stack the effect. However, at 10 stacks the perk glitches and causes stains to never fade.
    • Each use of the Perk Reroll machine doubles the cost of the next use. With significant prepwork it is possible to use the reroll enough times that the machines glitch and begin charging only single digits. This will work for nearly a thousand rerolls before the glitch corrects itself.
    • Spells with an infinite lifetime can be created due to an underflow error. Every projectile has a partially randomized lifetime which can be increased or decreased with certain modifiers. A spell with a -1 frame lifetime is treated as having an infinite lifetime, though a -2 or less lifetime will be treated as 0 lifetime spell.

    Role-Playing Games 
  • Chantelise: When the game time reaches, 99:99:99, it then overflows back to 0:00:00. Also, hacking for lots of money could lead to prices, since the price of things increase every buy, to overflow into negative numbers, and buying those objects may send your Pix count to overflow as well. Although, under normal play, pix are capped at some all 9s number, before it starts overflowing, to prevent overflow.
  • Dragon Ball Z: Buu's Fury has an objective early in the game where you have to get a Senzu Bean to give to Gohan so he can deliver it to an injured Videl. The thing is that Senzu Beans are also normal items that you can eat to heal back to full health and Ki, and this one is no different. If you eat the bean and then talk to Gohan to complete the objective, he takes one Senzu Bean from your zero Senzu Beans, resulting in an underflow that gives you 255 of them when the item normally has a cap of three.
  • Elden Ring has an interesting in-universe theological example. The goal of the Loathsome Dung Eater is to create a scenario where a god only interacts with its followers via curses. If this continues for long enough, then curses become that god's form of blessings, as they overwrite blessings in the rules of divine favor. That, in turn, makes people like the Dung Eater (who has made himself a walking stockpile of Seedbed Curses) what the Golden Order represents instead of what it stands against.
  • The Elder Scrolls V: Skyrim: It is possible to abuse the alchemy/enchanting loop to enhance gear so far it acquires negative armor or damage ratings.
  • Final Fantasy:
    • Final Fantasy IV has the "64 Door Hierarchy Glitch" which works on this principal. In a nutshell, the world map is "Room 0" and doors are listed as "Go" doors (increment it by 1) and "Return" doors (decrement it by one). In certain places it's possible to keep going through "Go" doors and keep increasing this number, and if you get it to 64 the number will roll over and whatever room you are in will become the new world map (Room 0). When this happens, if you then go through a "Return" door (or use Warp), all hell breaks loose.
    • In Final Fantasy VI, through the Sketch Glitch it is possible to obtain 256 copies of items. Attempting to sell them all at once rolls over from 255 to 0, and the shopkeeper will pay you nothing for them because the game thinks you're selling nothing.
    • Final Fantasy VII has an overflow glitch that causes the game to think that enemies have so much HP that it had better fix the problem and instantly kills them.
    • This error was one of the reasons why Final Fantasy XIV had a stat squish in Endwalker. Due to how drawing aggro works, the team cited that sometimes the tanks would generate so much aggro, it would roll over back to 0, causing the enemies to disengage the tank and target whomever was the second-highest. In an MMORPG, this is a huge no-no that would most certainly lead to a wipe.
    • This is why Benjamin's Cure spell deals massive damage to the Dark King in Final Fantasy Mystic Quest: it's coded such that its healing rolls over into being damage. Notably, only Benjamin's Cure spell can do this - Phoebe's Magic stat is high enough that it doubly rolls over, turning from healing to damage to healing again.
    • Overflow errors are common enough in older Final Fantasy titles that the Final Fantasy Wiki has a page listing them.
  • In Knights of the Old Republic II: The Sith Lords, a conversation option with your Wookiee teammate Hanharr allows you to break his will, reducing his Intelligence stat in exchange for a Strength increase. A Good Bad Bug left over from the game's Troubled Production lets you do this repeatedly, eventually sending him past zero and raising his Intelligence to the maximum possible value.
  • The Logomancer: In the RPGMaker.net version, defeating a Watcher of the Abyss underflows the Regret stat. This is changed to just being set to 0, in the Steam version.
  • A Game Mod for Pathfinder: Kingmaker raises the game's Absurdly Low Level Cap to 29 from 20. Reaching level 29 requires over 2 billion XP,note  and the notes for the mod state that a level cap of 30 would have an XP requirement higher than the 2.15 billion limit of a signed 32-bit integer.
  • In Persona games with social stats (at least confirmed for Persona 5 by modders), social stats have no hard cap even if the Player Character has reached max rank, meaning the value keeps increasing for every action that rewards points for that social stat (to be fair the values themselves are invisible outside of modifications, so most players do not know this). This keeps going until it reaches 32,767, at which point the stat ends up negative, resetting the stat's rank to 1.note  Considering the absurdly high number for this effect, a player either had to mess around with the game code, or chain New Game Plus playthroughs an insane number of times to see it.
  • One sidequest in Persona 4 asks for one Tetracorn and one Makaracorn. However, the game forgets to check if you have both, and if you have one but none of the other the quest will still complete and reduce your stock of both by 1. This underflows the missing type of corn from 0 to 99, giving you enough Attack Reflectors to last the whole game.
  • Pokémon:
    • The chance of a move's secondary effect activating is stored in one byte, so if it somehow reaches 256%, it'll be treated as 0%, and so on. This does not apply to the move's accuracy itself; "100%" accurate moves can miss in the first-generation main series games (but not Pokémon Stadium), though that's an off-by-one error, not an overflow. *
    • In the first two generations, the amount of experience each Pokémon needed to reach a specific level was determined by a formula. For a very specific subset of species, the value for a level 1 Pokémon was negative, so its experience value would underflow and it would be treated as level 100*. So if you're ever wondering why Pokémon Eggs hatched at level 5 before Generation IV, this is why.
    • In Pokémon Red and Blue, MissingNo. will always be at an absurdly high level due to the nature of the variables being read - namely, the characters in the player's name, which will always have a hexadecimal value above 100, the normal Cap. Attempting to level up your level 255 MissingNo. with a Rare Candy, however, will reset its level to 0, and attempting to train it at "legal" levels past this will prove difficult because without the advanced level multipliers, it's quickly found out the hard way that it has the 6th lowest base stat total of all Generation 1 Pokémon, only being beaten out by Magikarp and the not-fully-evolved bugs.
    • In Generation I, if a Pokémon has 255 or 511 HP, any attempts to use self-healing moves like Recover and Softboiled will fail.
    • Pokémon Gold and Silver:
      • The Thick Club held item can increase Marowak's Attack past 1023 (2^10-1), causing it to roll over to 0 and deal minimal damage.
      • If attempting to catch a wild Pokémon with more than 341 maximum HP, the game glitches out because the capture formula assumes HP*3 is supposed to be greater than HP. This can't happen without cheating, but if you're unlucky enough to be playing a ROM hack which spawns something with 342 HP, have fun reverting to your last save.
    • In Pokémon Ruby and Sapphire, attempting to sell 256 of an item gives you no money, because the game thinks you're selling 0 of that item. The only items stackable this high are Berries.
    • Pokémon Diamond and Pearl introduced the move Trick Room, which is supposed to invert Speed order. However, from Pokémon Black and White onwards, if a Pokémon has 1809 or more effective Speed, it still moves first. Explanation
    • Pokémon Sword and Shield has Eternamax Eternatus, an unplayable Pokémon with base Defense (and Special Defense) of 255, and thus a maximum of 658 in those stats if hacked into the party. Because the game multiplies the stat by 100 during certain calculations, and 65,800 > 65,535, it overflows into a ridiculously small Defense stat making it an unintentional Glass Cannon — or, if the stat is 656, it rolls over exactly to 0 when truncated, causing a Divide by Zero error which the game parses as "opposing attacks have zero power"!
  • This is done In-Universe in Super Paper Mario when Dimentio brings the heroes to a dimension of his own design that multiplies his powers 256-fold. Because of the overflow, his strength is reset. Not that it mattered; it also strengthened the heroes as well.
  • In Wild ARMs, there's an infinite item glitch where if the first two characters each use up one expendable item, then an item with quantity 1 is swapped into the inventory slot of that expendable item by the third character, when the turn finishes the game will subtract 2 from the quantity of the swapped item, leaving you with -1 of that item, or in the game's mind, 255.
  • An early port of "Wizard's Castle" for Microsoft BASIC or QBASIC had the player's bankroll of gold pieces stored as an integer variable. Most players that survive long enough to find the Runestaff, and thence the Orb of Zot, usually do so with less than 65,536 gold pieces on hand. However, for hearty souls bent on a dungeon clearing, the game crashed on the 65,536th coin. Later updates changed this to a single-precision variable.

    Shoot-'Em-Up 
  • Galaga, upon completion of Stage 255, attempts to begin Stage 0 and then crashes.
  • In Sinistar, if you get hit by a projectile and touch an enemy simultaneously while on your extra life, the game will subtract two lives, rolling backwards over 0 and reading it as 255 lives remaining.

    Simulation 
  • SimCity for the SNES had an integer underflow bug that could be triggered by tricking the budget screen into accepting to pay more money than you have for road/police/fire maintenance; money would then roll over to its capped value of $999,999.

    Sports 
  • Wii Sports: Your score in the minigame about returning tennis balls wraps around to 0 each time it goes over 255, but only when the game saves your score at the end. Proof here.

    Turn-Based Strategy 
  • Final Fantasy Tactics has an infinite Job Point glitch that can be invoked by selecting a skill to learn, pressing Page Down, then confirming. If the skill under the cursor after the Page Down cost more Job Points than were available, the number was subtracted from the current number of Job Points, rolling it over negative and giving the player thousands of free job points instead.
  • Fire Emblem: Path of Radiance: In the Japanese release, forging down the critical rate of a weapon with 5 base critical (like a Thunder tome) to 0 would underflow it to 255, creating a weapon that always lands critical hits. This was fixed in all other versions.

    Wide-Open Sandbox 
  • In the Wide-Open Sandbox spaceship game Frontier: Elite II, distances between stars were calculated using 16-bit values. This meant that a star about 655.36 lightyears away was treated as being close to zero lightyears away for fuel purposes. With a bit of trigonometry, this meant it was possible for players to plot a course between any two stars using only two hyperspace jumps. The "feature" was removed in later versions.
  • Minecraft
    • One of the game's most well-known glitches, the Farlands, was caused by a stack overflow. In beta versions of the game, traveling to a coordinate larger than the 32-bit integer limit would break the code for world generation, resulting in the normal Minecraft terrain ending in a massive, vertical wall, with holes dotted around like Swiss cheese.
    • Java Edition counts days up to the 64-bit integer limit. Once it overflows, the day/night cycle actually breaks and visually runs in reverse, resulting in mobs spawning in broad daylight, zombies and skeletons burning as well as spiders becoming passive during the night, etc. Of course, the amount of time it would take to overflow that day counter is a Time Abyss.
  • Terraria has a few.
    • Exceeding the 32-bit integer limit for the amount of times a monster has been killed in a given world will cause it to overflow to the negative limit, the only consequence is that the banner every 50 kills will no longer be rewarded until the counter hits 50 again.
    • Through a rather complicated setup involving the jousting lance (a weapon which increases in damage the faster you're moving), it's possible to overflow the display on the DPS Meter, resulting in a negative DPS reading, this number can even wrap around to the positives again, which displays as an unusually low number. MappyGaming elaborates more on this.

Examples in other media:

    Anime & Manga 
  • In one episode of Lupin III: Part 5, two guys build a safe that measures intelligence on a scale of 0-300 and can only be opened by someone whose intelligence is 0. Lupin's gang tries everything to lower Lupin's intelligence, but they can't get it low enough. Instead, Lupin eats lots of fish to increase his intelligence to 301, causing the safe to overflow back to 0 and open.

    Films — Live-Action 
  • The Andromeda Strain: The pathologists analysing the disease run a computer simulation of the casualties that would result if the contagion ever Escaped from the Lab. After blossoming from population hubs in the United States and Canada, the screen blanked to a single number: 808. The technician informs them that 808 means the computer can't calculate contamination levels that huge.

    Web Animation 
  • Referenced in Strong Bad Email: "4 branches" when Strong Bad talks about Homestar's occasional Genius Ditz moments:
    Strong Bad: You know how in video games, if you get the super-duper high score, it eventually flips back to zero? Well, sometimes Homestar does something so stupid, he flips back to smart.

    Webcomics 
  • In Level 30 Psychiatry Dr. Gardevoir and Roll happen on a bottle of Champagne that was left open since her graduation, with Gardevoir commenting that it's probably turned into vinegar at this point. Turns out, it overflowed and turned back into a bunch of fresh grapes. Roll even refers to it as a 256=0 issue.
  • xkcd:
    • A character gets thrown off by this while Counting Sheep, causing their mental image of the whole herd to stampede in the opposite direction. Whether it's a bigger problem to have one's brain throw an overflow error or to be awake even after 32,767 sheep (the limit of a signed 16-bit integer) is anyone's guess.
    • "Depth" features 32,767 angels dancing on the head of a pin — one more and they'd become 32,768 devils.
    • "Age Milestone Privileges" claims that when you turn 128 years old, your age overflows and you turn back into a baby.

    Real Life 
  • The Millennium Bug was a defied example of this trope. Due to resource constraints, early programmers stored the "year" variable as a two-digit number; however, this meant that when the year 1999, stored as "99", became the year 2000, it would roll over as 1900 instead, potentially causing unintended operation. Fortunately, the attention called to the impending problem prompted tech companies to spend the money needed to upgrade any remaining affected systems before the year 2000 hit, so only minor damage occurred.
  • It was a long-standing myth that images in the GIF format could only hold up to 256 colors because of the limits of most earlier PCs' video cards. They can hold more, but it's generally considered bad practice to do so except in large-filesize environments.
  • Chess.com, an online Chess app, crashed on 32-bit iOS devices once over 2^31 games had been started because of a signed integer game ID overflow in the 32-bit version of the app. The 64-bit iOS app was not vulnerable to this problem since the 64-bit version used a signed 64-bit integer game ID number instead of a 32-bit signed integer unlike the 32-bit version. A patched version was quickly rolled out once the overflow was diagnosed.
  • Overflow errors aren't limited to numbers. Lots of software bugs and exploits use them, by sending a much larger chunk of data than is expected by the receiving software. Heartbleed is an overflow in reverse. One sends a very small piece of data to the server, and asks for a very large piece in return.
  • Many electronic scoreboards only have room for two digits, meaning in the event of a team reaching 100 or more points, the scoreboard will display "00" again, and it'll be up to the coach and audience to keep track of what the true score is. Of course, depending on the sport, that might be highly implausible (three digit scores in basketball are fairly common, but in soccer and hockey, it's not that unlikely for the combined score of both teams to still be in the single digits when the game ends).
    • In a 2015 Pennsylvania high school football game, the visiting Meadville Bulldogs defeated the Dubois Beavers by the otherworldly score of 107-90. Again, this was a football game. The scoreboard at the Dubois stadium could only handle double digits, so Meadville's final score was shown as "07" on the scoreboard.
  • On the very rare occasions where a cricket score has gone over 1000 runs in an innings, the same problem applies: cricket scoreboards do not run to four places.
  • The Therac-25, a machine built for radiation therapy, had one that killed people. In short, the machine recorded whether or not its hardware was in the correct rotation by incrementing an 8-bit variable, which flowed over on every 256th increment and bypassed the safety checks.
  • "Gangnam Style", the most viewed video on YouTube until Wiz Khalifa's "See You Again" came along, very nearly broke the site's view counters when the number of views went over 2,147,483,647, the maximum value of a 32-bit signed integer; YouTube had to upgrade to 64-bit signed integers capable of holding values up to 9,223,372,036,854,775,807 afterwards.

Alternative Title(s): Underflow Error, Integer Overflow, Integer Underflow

Top