Bitcoin Forum

Bitcoin => Bitcoin Discussion => Topic started by: libert19 on February 22, 2023, 05:12:15 AM



Title: What does 'int' mint in Bitcoin
Post by: libert19 on February 22, 2023, 05:12:15 AM
Pardon my ignorance. I just read this sentence and I don't get it.

"There should not be any signed int. If you've found a signed int somewhere, please tell me (within the next 25 years please) and I'll change it to unsigned int." -- Satoshi



Title: Re: What does 'int' mint in Bitcoin
Post by: pooya87 on February 22, 2023, 05:23:36 AM
"int" is short for integer which is a whole number (without fraction) that can be positive, negative, or zero. https://en.wikipedia.org/wiki/Integer


Title: Re: What does 'int' mint in Bitcoin
Post by: NeuroticFish on February 22, 2023, 11:20:17 AM
It's about a data type in the code or data.

The thing is that a signed int (32 bit signed integer) takes values between -2,147,483,648 and 2,147,483,647,
while unsigned int goes between 0 and 4,294,967,295

Clearly Satoshi meant that in case an error is found in his code, that has to be fixed before a big number is reached (bigger than 2,147,483,647), because in case of signed int that will mean an overflow (https://en.wikipedia.org/wiki/Integer_overflow) to negative numbers.


Title: Re: What does 'int' mint in Bitcoin
Post by: DdmrDdmr on February 22, 2023, 11:53:47 AM
The origin of the comment is related to assuring that the code’s timestamp fields were not potentially subject to the Y2038 overflow problem (https://en.wikipedia.org/wiki/Year_2038_problem) (on 32 bit signed integers), as depicted in this thread (https://bitcointalk.org/index.php?topic=760.msg8413#msg8413). 32 bit unsigned integers manage to postpone the problem (https://en.bitcoin.it/wiki/Block_timestamp) until next century ...

I figure that the core code has been verified on multiple occasions to be Y2038 free, though in general terms, we’d likely hear quite a bit about it as we close into the said year.