Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: wsxdrfv on March 20, 2018, 03:27:51 AM



Title: What is maximum possible number for MAX_MONEY variable?
Post by: wsxdrfv on March 20, 2018, 03:27:51 AM
So bitcoin's Max_Money is 21,000,000

From programming perspective, what number this can be at its max?

Is that can be like 100000000000000000?

I know Bitcoin go down to up to 8 decimal places, 0.00000001 Bitcoin.

Is this right?

Then I think this also can affect to maximum possible number?


Title: Re: What is maximum possible number for MAX_MONEY variable?
Post by: Thanks1 on March 20, 2018, 04:51:38 AM
So bitcoin's Max_Money is 21,000,000

From programming perspective, what number this can be at its max?

Is that can be like 100000000000000000?

I know Bitcoin go down to up to 8 decimal places, 0.00000001 Bitcoin.

Is this right?

Then I think this also can affect to maximum possible number?
Max 21,000,000


Title: Re: What is maximum possible number for MAX_MONEY variable?
Post by: Heisenberg_Hunter on March 20, 2018, 05:16:38 AM
No, I think you might be wrong in understanding the Max_Money variable. Max_Money is rather a sanity check and not the total money supply which when said in bitcoin is less than 21,000,000. This Max_Money constant is used to prevent people from doing a transaction not more than 21,000,000. For example if there happens to be a overflow bug within the network that happens to create a coin out of simple modification leads to a fork.

The total supply of btc will always be less than 21,000,000.

Code:
 Subsidy is cut in half every 210000 blocks, which will occur approximately every 4 years
    nSubsidy >>= (nHeight / 210000);

Which means when the first 210000 blocks are created, the mining rewards were 50btc, and the next 210,000 blocks the reward is cut in half to 25 btc and the next 210000 blocks the reward is cut in half to 12.5 btc. This process continues till the total coins are mined out which will be equal to 20999999.9769btc which is approximately equal to 21 million.

We can even change the original value, to a higher value but it would disturb the integrity of community and the limit set by satoshi

I am not good in explaining programming techniques. Correct me if I am wrong :P


Title: Re: What is maximum possible number for MAX_MONEY variable?
Post by: HeRetiK on March 20, 2018, 01:06:50 PM
From programming perspective, what number this can be at its max?

If by programming perspective you mean the data type being used -- currently Bitcoin uses 64 bit integers for transaction amounts.

Since one bit is being used for the sign (+/-) the largest number this data type can handle is 2^63 = 9,223,372,036,854,775,807 (= 9.22e+18)

So yeah, from a data type perspective it could be "something like 100000000000000000" (= 1.0e+17).

But no, from a protocol perspective such a transaction would be invalid.


Title: Re: What is maximum possible number for MAX_MONEY variable?
Post by: wsxdrfv on March 21, 2018, 04:00:56 AM
From programming perspective, what number this can be at its max?

If by programming perspective you mean the data type being used -- currently Bitcoin uses 64 bit integers for transaction amounts.

Since one bit is being used for the sign (+/-) the largest number this data type can handle is 2^63 = 9,223,372,036,854,775,807 (= 9.22e+18)

So yeah, from a data type perspective it could be "something like 100000000000000000" (= 1.0e+17).

But no, from a protocol perspective such a transaction would be invalid.

Yes, so I meant, when someone make new alt-coin, I wondered how much that MAX_MONEY variable's value could be.

So then, Bitcoin's cases used 21,000,000 * COIN, so this COIN variable means so-called, Satoshi, and this can go below decimal 8

places, then actual Bitcoin's program can handle 21,000,000 * 10,000,000 = 210,000,000,000,000?

So this places in range of above you mentioned, 9,223,372,036,854,775,807

Then, new alt-coin's maximum possible value also should be in range of above, 9,223,372,036,854,775,807 / 10,000,000 (for satoshi, COIN variable) = 92,233,720,368

So total supply of alt-coin should be below than 92,233,720,368 ?


Title: Re: What is maximum possible number for MAX_MONEY variable?
Post by: DannyHamilton on March 21, 2018, 03:20:29 PM
From programming perspective, what number this can be at its max?

If by programming perspective you mean the data type being used -- currently Bitcoin uses 64 bit integers for transaction amounts.

Since one bit is being used for the sign (+/-) the largest number this data type can handle is 2^63 = 9,223,372,036,854,775,807 (= 9.22e+18)

So yeah, from a data type perspective it could be "something like 100000000000000000" (= 1.0e+17).

But no, from a protocol perspective such a transaction would be invalid.

Yes, so I meant, when someone make new alt-coin, I wondered how much that MAX_MONEY variable's value could be.

So then, Bitcoin's cases used 21,000,000 * COIN, so this COIN variable means so-called, Satoshi, and this can go below decimal 8

places, then actual Bitcoin's program can handle 21,000,000 * 10,000,000 = 210,000,000,000,000?

So this places in range of above you mentioned, 9,223,372,036,854,775,807

Then, new alt-coin's maximum possible value also should be in range of above, 9,223,372,036,854,775,807 / 10,000,000 (for satoshi, COIN variable) = 92,233,720,368

So total supply of alt-coin should be below than 92,233,720,368 ?

Unless you ALSO change the value of COIN or you change the code to use something larger than 64 bit integers.  If you do that then you can have ANY VALUE YOU WANT.


Title: Re: What is maximum possible number for MAX_MONEY variable?
Post by: btcton on March 21, 2018, 10:23:41 PM
From programming perspective, what number this can be at its max?

If by programming perspective you mean the data type being used -- currently Bitcoin uses 64 bit integers for transaction amounts.

Since one bit is being used for the sign (+/-) the largest number this data type can handle is 2^63 = 9,223,372,036,854,775,807 (= 9.22e+18)

So yeah, from a data type perspective it could be "something like 100000000000000000" (= 1.0e+17).

But no, from a protocol perspective such a transaction would be invalid.

Yes, so I meant, when someone make new alt-coin, I wondered how much that MAX_MONEY variable's value could be.

So then, Bitcoin's cases used 21,000,000 * COIN, so this COIN variable means so-called, Satoshi, and this can go below decimal 8

places, then actual Bitcoin's program can handle 21,000,000 * 10,000,000 = 210,000,000,000,000?

So this places in range of above you mentioned, 9,223,372,036,854,775,807

Then, new alt-coin's maximum possible value also should be in range of above, 9,223,372,036,854,775,807 / 10,000,000 (for satoshi, COIN variable) = 92,233,720,368

So total supply of alt-coin should be below than 92,233,720,368 ?

Unless you ALSO change the value of COIN or you change the code to use something larger than 64 bit integers.  If you do that then you can have ANY VALUE YOU WANT.

At this point I would be drawing at hypotheticals, but depending on the data type you use (in this case int64 or wider) it could also have effects on the kind of network protocol used. The bigger the data type, the more data would be required per possible transaction. To be fair, this would have to be an extremely large number, but it is nonetheless also important to consider in cases in which an altcoin could potentially be used as a more private, smaller coin that is not used by many and does not require a high quantity thereof. In such a case, one could use an int32 that would occupy only half of the space, albeit it would be much more limited in quantity to around 4 million minimum-denomination coins (satoshi equivalents) or around 40 coins if the same decimal levels as Bitcoin were used. It is worth mentioning that there are definitely useful use-cases for this, although maybe not so much for, say, a 128-bit data type.


Title: Re: What is maximum possible number for MAX_MONEY variable?
Post by: samson on March 24, 2018, 09:55:13 AM
From programming perspective, what number this can be at its max?

If by programming perspective you mean the data type being used -- currently Bitcoin uses 64 bit integers for transaction amounts.

Since one bit is being used for the sign (+/-) the largest number this data type can handle is 2^63 = 9,223,372,036,854,775,807 (= 9.22e+18)

So yeah, from a data type perspective it could be "something like 100000000000000000" (= 1.0e+17).

But no, from a protocol perspective such a transaction would be invalid.

Yes, so I meant, when someone make new alt-coin, I wondered how much that MAX_MONEY variable's value could be.

So then, Bitcoin's cases used 21,000,000 * COIN, so this COIN variable means so-called, Satoshi, and this can go below decimal 8

places, then actual Bitcoin's program can handle 21,000,000 * 10,000,000 = 210,000,000,000,000?

So this places in range of above you mentioned, 9,223,372,036,854,775,807

Then, new alt-coin's maximum possible value also should be in range of above, 9,223,372,036,854,775,807 / 10,000,000 (for satoshi, COIN variable) = 92,233,720,368

So total supply of alt-coin should be below than 92,233,720,368 ?

Unless you ALSO change the value of COIN or you change the code to use something larger than 64 bit integers.  If you do that then you can have ANY VALUE YOU WANT.

At this point I would be drawing at hypotheticals, but depending on the data type you use (in this case int64 or wider) it could also have effects on the kind of network protocol used. The bigger the data type, the more data would be required per possible transaction. To be fair, this would have to be an extremely large number, but it is nonetheless also important to consider in cases in which an altcoin could potentially be used as a more private, smaller coin that is not used by many and does not require a high quantity thereof. In such a case, one could use an int32 that would occupy only half of the space, albeit it would be much more limited in quantity to around 4 million minimum-denomination coins (satoshi equivalents) or around 40 coins if the same decimal levels as Bitcoin were used. It is worth mentioning that there are definitely useful use-cases for this, although maybe not so much for, say, a 128-bit data type.

He could double up by using a uint32 instead of int32, why use int32 anyway ? Are negative numbers used anywhere ?

There's a few weird decisions made long ago which seem to be trivial and add complexity where it's not really needed, I guess this was the programming style of the original programmer.