user44: Since bitcoins are being regularly rewarded to miners, will the number of bitcoins continue to grow indefinitely, or will there be a maximum total number of bitcoins in existence?  And if there is some kind of limit, what is it and how is it enforced?

user12311: Re. 'how is it enforced?': 
The 21 million limit is enforced by game theory. Theoretically, 50% of miners could adopt code that would increase the rate of production but this would break the social contract that Satoshi created, irrevocably harm the integrity of bitcoin, and crash the price. Therefore, anyone or any group that could change the limit is incentivized to not do so.  

user3228: As per the current rules there will only ever be 21 million coins at most (explained in other answers here). However, I'd like to add that this is by general agreement, which means that it can be changed.
See this question: Could there be hyperinflation in Bitcoin?
Looking at the history of money, I am skeptical that there will only ever be 21 million coins. I don't know of too many instances in history when money could be created out of thin air and wasn't. It would be foolish to ignore history. Whether or not there will be more than 21 million coins depends on whether or not "the people" demand it, and once again history is our guide.

user18656: According to a BIP (Bitcoin Improvement Proposal) I found, this code:
 nSubsidy >>= (nHeight / 210000);

will actually wrap the reward generation back to 50 at some point in 2200 or so. Making the supply of bit coins infinite. The python code above does not have this property. The C++ code does. See BIP https://github.com/bitcoin/bips/blob/master/bip-0042.mediawiki

user2306: 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.

user44: A pre-defined schedule limits the total number of bitcoins so that they gradually approach a total of 21 million (ignoring those that have been lost through deleted or misplaced wallet files).  The limit of 21 million bitcoins is "hard-wired" in to the protocol, and there will never be more bitcoins than this:


user8: Every block introduces 50 new coins in the system. This quantity (50) halves every 210,000 blocks. So, getting the limit of coins it is possible to generate is quite easy : it's the sum of a geometric series.

Also, note that this is an upper bound ; the actual quantity will probably be a bit lower due to rounding issues (BTC has a finite number of decimals, 8).

44: <p>Since bitcoins are being regularly rewarded to <a href="https://en.bitcoin.it/wiki/Category%3aMining">miners</a>, will the number of bitcoins continue to grow indefinitely, or will there be a maximum total number of bitcoins in existence?  And if there is some kind of limit, what is it and how is it enforced?</p>
 12311: <p>Re. 'how is it enforced?': 
The 21 million limit is enforced by game theory. Theoretically, 50% of miners could adopt code that would increase the rate of production but this would break the social contract that Satoshi created, irrevocably harm the integrity of bitcoin, and crash the price. Therefore, anyone or any group that could change the limit is incentivized to not do so.  </p>
 3228: <p>As per the <strong>current rules</strong> there will only ever be 21 million coins at most (explained in other answers here). However, I'd like to add that this is by general agreement, which means that it <strong>can be changed</strong>.</p>

<p>See this question: <a href="https://bitcoin.stackexchange.com/questions/8776/could-there-be-hyperinflation-in-bitcoin">Could there be hyperinflation in Bitcoin?</a></p>

<p>Looking at the history of money, I am skeptical that there will only ever be 21 million coins. I don't know of too many instances in history when money could be created out of thin air and wasn't. It would be foolish to ignore history. Whether or not there will be more than 21 million coins depends on whether or not "the people" demand it, and once again history is our guide.</p>
 18656: <p>According to a BIP (Bitcoin Improvement Proposal) I found, this code:</p>

<pre><code> nSubsidy &gt;&gt;= (nHeight / 210000);
</code></pre>

<p>will actually wrap the reward generation back to 50 at some point in 2200 or so. Making the supply of bit coins infinite. The python code above does not have this property. The C++ code does. See BIP <a href="https://github.com/bitcoin/bips/blob/master/bip-0042.mediawiki" rel="noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0042.mediawiki</a></p>
 2306: <p>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.</p>

<p>I found that number through the following python program:</p>

<pre><code>COIN = 100 * 1000 * 1000
nSubsidy = 50 * COIN
nHeight = 0
total = 0
while nSubsidy != 0:
    nSubsidy = 50 * COIN
    nSubsidy &gt;&gt;= nHeight / 210000
    nHeight += 1
    total += nSubsidy

print total / float(COIN)
</code></pre>

<p>It's intended to mirror this code from the Bitcoin client:</p>

<pre><code>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 &gt;&gt;= (nHeight / 210000);

    return nSubsidy + nFees;
}
</code></pre>

<p>Of course, it only differs from 21 million BTC by only 3 bitcents, so the difference isn't significant.</p>
 44: <p>A pre-defined schedule limits the total number of bitcoins so that they gradually approach a total of 21 million (ignoring those that have been lost through deleted or misplaced wallet files).  <strong>The limit of 21 million bitcoins is "hard-wired" in to the protocol</strong>, and there will never be more bitcoins than this:</p>

<p><img src="https://i.stack.imgur.com/JLm1p.png" alt="The Schedule on which Bitcoins are released into the economy through being rewarded to miners"></p>
 8: <p>Every block introduces 50 new coins in the system. This quantity (50) halves every 210,000 blocks. So, getting the limit of coins it is possible to generate is quite easy : it's the sum of a geometric series.</p>

<p><img src="https://i.stack.imgur.com/tTVgM.gif" alt="latex formula"></p>

<p>Also, note that this is an upper bound ; the actual quantity will probably be a bit lower due to rounding issues (BTC has a finite number of decimals, 8).</p>
