Home Bitcoin reward schedule – If there are 32 halvings, why is the if block within the GetBlockSubsidy perform checking if there are 64 or extra halvings already executed?

reward schedule – If there are 32 halvings, why is the if block within the GetBlockSubsidy perform checking if there are 64 or extra halvings already executed?

0
reward schedule – If there are 32 halvings, why is the if block within the GetBlockSubsidy perform checking if there are 64 or extra halvings already executed?

[ad_1]

Variable nsubsidy is of sort CAmount which is an int64.

Because the feedback say within the code you quoted, a 64-bit integer worth can have not more than 64 bitwise right-shift operations meaningfully carried out. So that is the restrict utilized.

It simply occurs that the preliminary subsidy 50 * COIN is a a lot smaller worth that falls to zero solely round 32 bitwise proper shifts.

So the restrict is predicated on the information sort not the preliminary worth. Whatever the preliminary worth, we all know that the outcome should be zero after a 64-bit variable is true shifted 64 occasions.

A bitwise rightshift is a fairly low-cost operation in CPU cycles so there’s most likely not a lot to be gained by optimising additional right here.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here