36

There has been a story in the news about a man whose Paypal account was accidentally credited with $92,233,720,368,547,800.

Where does this number come from? What sort of programming bug is likely to give rise to this number?

gnat
  • 21,442
  • 29
  • 112
  • 288
shamp00
  • 2,759
  • 3
  • 18
  • 14
  • 5
    I'm voting to close this question as off-topic because it is not a conceptual programming problem within the scope defined in the help center. –  Jul 13 '15 at 15:22

1 Answers1

58

It's the maximum value of a long (64 bit signed integral type).

from http://msdn.microsoft.com/en-us/library/system.int64.maxvalue.aspx

The value of this constant is 9,223,372,036,854,775,807; that is, hexadecimal 0x7FFFFFFFFFFFFFFF.

This would be the maximum value for a 64-bit signed integral type in any language, I'm not assuming paypal uses .NET, the link to MSDN above is just illustrative.

The error is likely just a poor conversion error (like from decimal or float or etc to long that didn't work correctly) resulting in some overflowing of a value, or bad defaulting code for some strange scenario, or it could have been a test in production by their engineering/QA team gone hay-wire. Memory leak/pointer error, the list of ways to cause this are really countless. Could have been a parsing error deserializing some information that came to them across the wire, tremendously numerous ways to accidentally end up with an unexpected or misaligned integral value.

Jimmy Hoffa
  • 16,039
  • 3
  • 69
  • 80
  • 1
    even more odd is that the number was apparently rounded up to the nearest $100 dollars. – KutuluMike Jul 19 '13 at 20:16
  • 4
    Why are the numbers in the question and answer not the same? – thursdaysgeek Jul 19 '13 at 22:46
  • 3
    Because the integer value is a count of pennies. So you divide 2^63-1 by 100 to get dollars. And then something rounded to the nearest $100 for some reason. – Mark Adler Jul 20 '13 at 00:06
  • 4
    @thursdaysgeek some math went wrong enough to cause an integral overflow, chances are in the process of the code getting math wrong it continued calculating some operations after the overflow occurred causing the amount to change even more. As if the equation was 2+3*4*8/22+400^2 and on the second step an overflow occurs, the folowing operations will continue applying to that incorrect number. – Jimmy Hoffa Jul 20 '13 at 00:26