As Artefact2 mentioned, Bitcoin uses fixed-point math to calculate the block subsidies. So, ignoring the unspendable genesis block, the sundry lost coins and unclaimed rewards, the maximum number of bitcoins is 20999999.9769 BTC.
I found that number through the following python program:
COIN = 100 * 1000 * 1000
nSubsidy = 50 * COIN
nHeight = 0
total = 0
while nSubsidy != 0:
nSubsidy = 50 * COIN
nSubsidy >>= nHeight / 210000
nHeight += 1
total += nSubsidy
print total / float(COIN)
It's intended to mirror this code from the Bitcoin client:
int64 static GetBlockValue(int nHeight, int64 nFees)
{
int64 nSubsidy = 50 * COIN;
// Subsidy is cut in half every 210000 blocks, which will occur approximately every 4 years
nSubsidy >>= (nHeight / 210000);
return nSubsidy + nFees;
}
Of course, it only differs from 21 million BTC by only 3 bitcents, so the difference isn't significant.
3I think that's very unlikely. Even if there are a few precipitous drops, I think that will be outweighed by the overall trend of increasing hashing power (and they'll be followed be precipitous drops in difficulty). But, yes, that is possible. – David Schwartz – 2011-08-31T00:04:11.590
1I think saying "hard wired" is a bit misleading. The production schedule is coded in the software and could be changed to create more bitcoin. Fortunately anyone or any group that could change it is strongly incentivized to maintain the limit as it is integral to our idea of and trust in bitcoin. – Alex Millar – 2016-02-26T16:30:06.270
5Note that there are some assumptions built into the timing and unless the protocol is changed, they will actually be mined a bit earlier than this chart suggests. – David Schwartz – 2011-08-31T00:00:03.530
4Or later--if the value drops precipitously and difficulty takes a while to get low enough again. But the graph is a good rough approximation. – eMansipater – 2011-08-31T00:02:37.397