Security News > 2021 > May > Never say never! Warren Buffett caught up in integer overflow error…

Never say never! Warren Buffett caught up in integer overflow error…
2021-05-10 19:56

UK clothing chain Next is currently worth more than $10,000 a share on the London Stock Exchange, for example, and Swiss chocolatiers Lindt are currently trading at over $100,000 a share on the SIX Swiss Exchange.

So if you wanted to record share prices with an accuracy of 1/100 of a US cent, you'd need to be able to represent numbers up to and beyond 1,000,000,000 , because there are one billion ten-thousandths of a dollar in $100,000.

232−1 = 4,294,967,295, which assembler programmers will tell you off the top of their heads, although they cheat by using base 16, where the value just happens to come out as the easily-remembered 0xFFFFFFFF. So if you use a 32-bit unsigned integer that takes up four bytes of memory, you can exactly represent any share price from $0 to $429,496.

Of course, most computers these days happily and efficiently handle 64-bit integers in calculations, but they consume eight bytes each, and given that Lindt and Next are amongst the priciest shares you can buy right now, more than half the bits in every share price you stored would in theory be wasted if you went for 64 bits instead of 32.

The problem is that the most expensive individual share you can buy right now is not Next or Lindt, but BRK-A, the ticker abbreviation for Warren Buffett's famous Berskshire Hathway Inc. And those shares, when last we looked, cost an eye-watering $442,512 each, which comes out at 4,425,120,000 ten-thousandths of a dollar, or 0x107C1F900 in hexadecimal, up from just over $400,000 a month ago.

The New York Stock Exchange, on which BRK-A shares are actually listed, doesn't seem to store its prices the same way as Nasdaq, and therefore wasn't affected by the BRK-A price climbing to $429,497 and beyond.


News URL

https://nakedsecurity.sophos.com/2021/05/10/never-say-never-warren-buffett-caught-up-in-integer-overflow-error/