World of Warcraft Gold Limit Reached, It's 2^31
Mitch writes "Blizzard apparently used signed integers for their World of Warcraft gold values as some people have recently hit the limit of 2^31. "Apparently that amount is 214,748 gold, 36 silver, 48 copper. After you reach that lofty sum, you'll no longer be able to receive money from any source in the game. While some responses to the original posts claim that this exact limit had previously been theorized to exist, there have been no reports of anyone in the game actually achieving this amount via legal means." I guess Blizzard didn't expect anyone to ever get close to that much gold in game."
There's not a real economy in WoW, per say. You get most of your money from quests and kills, which is pretty well-regulated (in the sense that lower level mobs and quests give lower amounts of money, and there's a limit to what you can kill and loot), and you spend most of it in NPC shops. The only semblance of an economy is the auction house and trade channels.
The fact that most of your money disappears into NPC shops with set prices keeps inflation from happening.
Do you have any gathering professions? I can make 100+ just buy selling a few stacks of adamantite ore (plus the eternium and gems) that I get from mining in a short amount of time. When my first (and only) toon hit 70, he already had about 3000g mostly from the quests going from 60 to 70. On top of that, factor in daily quests which give you ~12g per quest, which you can do up to 10 of per day; 12g * 10 = another 120g per day per character.
The range for a signed integer is 2,147,483,648 to +2,147,483,64_7_ (not 8).
The negative range always extends one higher, since zero uses the first "positive" value.
I call fabrication. And I call O.o for slashdotters not realizing this sooner.
Signed integers are used all the time for strictly positive values. For most purposes it is more convenient to just utilize the standard signed integer, and perform range checking to ensure it's positive.
(You need to range check unsigned integers too, it's not as if switching to an unsigned integer relieves you of any problems, other than that it increases the 2^31-1 limit to a 2^32-1 limit.)
The player should be thankful that the only consequence is they can't receive more gold from other players, rather than finding they have a _VERY_ negative amount of gold (less than zero).
In many C based programs, your gold would overflow and drop to (-2^31+1), -2147483647, since the C programming language doesn't offer the programmer any exception handling mechanism for overflow detection (overflows are silently allowed to happen), and game developers don't necessarily anticipate such extremes.