This article is more than 1 year old

Nasdaq's 32-bit code can't handle Berkshire Hathaway's monster share price

Now that's what we call a Buffett overflow error

Bug of the week Here's a programming gremlin that caught our eye this week: a share price exceeded the 32-bit unsigned integer limit of a stock exchange's code.

Berkshire Hathaway is an investment group known not just for being run by billionaire tycoon Warren Buffett, but also because its BRK.A stock is ridiculously priced: at time of writing, $435,120.00 (£312,818.65) apiece. It is listed on the New York Stock Exchange, which is unaffected by the following bug.

On Tuesday, the Nasdaq exchange ceased transmitting information about the stock on its website and in certain feeds to brokers and other financial organizations. The webpage for the stock simply says: "Data is currently not available." Nasdaq's Last Sale, Last Sale Plus, Last Sale FilterView, and Basic are paused for now.

And that's because the BRK.A value was on course to exceed, and did eventually exceed, the maximum value that some parts of Nasdaq's software can safely handle.

It turns out Nasdaq uses 32-bit unsigned integers to record and send quotes for shares. The maximum value of such a 32-bit variable is 232 - 1, or 0xffffffff in hexadecimal, or 4,294,967,295 in decimal.

Nasdaq decided not to store prices using a floating-point number format normally found in applications, probably because they can be approximate, and instead chose to multiply quotes by 10,000 and store them as 32-bit unsigned integers. For example, the value 123,456 would represent a stock price of $12.3456, precise down to the hundredth of a penny. The value 7,890,000 would represent a stock price of $789.0000.

And so BRK.A's $435,120.0000 price would be stored as 4,351,200,000, which exceeds the 4,294,967,295 maximum, and would overflow to some value far lower than the actual stock price. In effect, the value would wrap around from the maximum to zero, and in fact go past zero to 56,232,704, or $5,623.2704.

If the faulty price was broadcast to the world by Nasdaq, there would be bedlam. Imagine thinking you could snap up Berkshire Hathaway shares for less than $6,000 apiece, or that your holdings of the stock were suddenly ruined?

On May 4, Nasdaq stopped BRK.A's data going out before it overflowed, and said it will have a fix in place by May 17.

"Trade data messages distributed via Nasdaq Last Sale and its iterations have a maximum allowable value of $429,496.7295, due to its 4-byte length," the exchange said in a note to investors. "Nasdaq will suspend the publication of last sale information through its proprietary data products for any security that breaks the 98 percent pricing threshold within a trading session, or $420,906.794, beginning May 4, 2021, to ensure that no incorrect pricing data is published."

A solution would be to use 64-bit unsigned integers, giving you the ability to handle a maximum value of 18,446,744,073,709,551,615, or a share price of $1,844,674,407,370,955.1615. That's plenty of breathing room, for now. And that's what Nasdaq appears to be doing, with its 64-bit Long Form Price Messages that will be rolled out later this month.

The 90-year-old Buffett won't budge on splitting his group's class A stock, for what it's worth, which is why it's so much higher than anything else on the market.

Meanwhile, the IEX Exchange stopped accepting orders for BRK.A in mid-March "due to an internal price limitation within the trading system. Any orders sent in this symbol will be rejected until further notice." To us, that sounds like it suffered the same problem as Nasdaq.

Aptly, BRK is a 6502 CPU assembly code mnemonic for a breakpoint, which can be used to troubleshoot a program that's gone wrong. ®

Editor's note: This article was revised after publication to include the list of affected Nasdaq services. A spokesperson for the exchange told us its Trade Reporting Facility (TRF) does not have a 32-bit limit, and is used for the majority of BRK.A trading. Also, hat tip to the Wall Street Journal for highlighting this flaw earlier this week.

More about

TIP US OFF

Send us news


Other stories you might like