first and foremost I never read the bitcoin source code (I can't read any C) and I was wondering if Bitcoin, and any other crypto currency follow that they have data limits such as a maximum value of a long int is 4,294,967,295. If that case is true what would happen when the difficulty goes above the long int value. Hopefully this makes sense in how I worded it.

  • 1
    Its C++ by the way, not C.
    – Jori
    Feb 18 '14 at 16:52
  • According to the bitcoin.it wiki the limit for the difficulty is 2^224, I think we can be fairly certain that it isn't stored as an int.
    – Murch
    Feb 19 '14 at 13:42
  • I was just giving a random example of a data type
    – rdadkins
    Feb 19 '14 at 13:44
  • @fatso113, Yes I thought you meant that, that's why I answered you question like that instead of: its stored as float/double.
    – Jori
    Feb 19 '14 at 17:48

Of course they make use of these datatypes. They have to because it is how the CPU is constructed, the CPU and its instruction set architecture (ISA) work with fixed amounts of memory. This can be different per instruction, but can not be arbitrary.

If you need to perform arithmetic on arbitrary sized words, your only option is a software approach called a BigNum library. Bitcoin uses a BigNum library too (I believe some Boost stuff, but correct if I'm wrong). Examples include but are not limited to: GMP, Java's BigInterger class.

  • So in theory, the use of big integer will allow the difficulty to increase forever or would there be a limit on the number in terms of CPU or how it was written in the the program?
    – rdadkins
    Feb 18 '14 at 17:26
  • There is no real limit, although most libraries will require the operands to be in memory. So your main memory will be the limiting factor, which is pretty big, e.x. 8 GB vs 32 bits.
    – Jori
    Feb 18 '14 at 18:04
  • Such 'arbitrary limits' have nothing to do with the libraries or CPU used, instead they are dictated by the designed layout of the network messages (and also by the byte layout of data that has to be hashed/signed in a reproducible way). The 'difficulty' field for example has been carefully designed to cover the full range needed without covering all intermediate values, which is fine for its use. The 'version' field on the other hand can handle 2^32 values which is more than overkill for its purpose.
    – Anonymous
    Feb 19 '14 at 15:47
  • I don't get your point. This data needs to be calculated and stored first before going through the whole network layer. The CPU has to handle this, so this data can't be larger than what the CPU imposes (unless you use some software based approach, or perhaps even special hardware I don't know about).
    – Jori
    Feb 19 '14 at 17:45
  • Your question was about arbitrary limits in Bitcoin and similar crypto currencies. Your thinking now seems to have switched to be CPU - centric. If the hardware you use is Turing-complete then the 'software based approach' you mention is how mismatch in word-size between hardware and protocol is typically handled. For completeness: yes the bitcoin protocol seems 'inspired' by 32-bit hardware but is not limited by it.
    – Anonymous
    Feb 21 '14 at 10:09

The difficulty is determined by a 256 bit target. Miners must find a hash for the block that is below this target. The target decreases or increases to adapt to the desired block time (10 minutes in the case of Bitcoin).

Pools usually calculate difficulty as a float for their stats because it doesn't need to be very precise. The actual difficulty is determined by the 256 bit target.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.