<p>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.</p>

<p>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: <a href="https://gmplib.org" rel="nofollow">GMP</a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/math/BigInteger.html" rel="nofollow">Java's BigInterger class</a>.</p>

CC BY-SA 3.0
2014-02-18T17:26:43.153Z
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
CC BY-SA 3.0
2014-02-18T18:04:57.080Z
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
CC BY-SA 3.0
2014-02-19T15:47:45.930Z
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
CC BY-SA 3.0
2014-02-19T17:45:41.923Z
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
CC BY-SA 3.0
2014-02-21T10:09:44.320Z
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
CC BY-SA 3.0
2014-02-18T17:01:00.553Z
2014-02-18T17:01:00.553Z
Jori
<p>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).</p>

<p>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.</p>

CC BY-SA 3.0
2014-02-18T17:05:10.477Z
2014-02-18T17:05:10.477Z
Diego Basch
<p>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.</p>

CC BY-SA 3.0
2014-02-18T16:52:26.297Z
Its C++ by the way, not C.
Jori
CC BY-SA 3.0
2014-02-19T13:42:42.170Z
According to the [bitcoin.it wiki](https://en.bitcoin.it/wiki/Difficulty#What_is_the_maximum_difficulty.3F) the limit for the difficulty is 2^224, I think we can be fairly certain that it isn't stored as an int.
Murch
CC BY-SA 3.0
2014-02-19T13:44:49.537Z
I was just giving a random example of a data type
rdadkins
CC BY-SA 3.0
2014-02-19T17:48:16.620Z
@fatso113, Yes I thought you meant that, that's why I answered you question like that instead of: its stored as float/double.
Jori
<difficulty>
Data type limit boundary in difficulty
rdadkins
# Data type limit boundary in difficulty

(Asked by: username_0 on 2014-02-18)

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.

**Tags:** difficulty

> **Comments:**
> **username_1**: Its C++ by the way, not C.  
> **username_2**: According to the [bitcoin.it wiki](https://en.bitcoin.it/wiki/Difficulty#What_is_the_maximum_difficulty.3F) the limit for the difficulty is 2^224, I think we can be fairly certain that it isn't stored as an int.  
> **username_0**: I was just giving a random example of a data type  
> **username_1**: @fatso113, Yes I thought you meant that, that's why I answered you question like that instead of: its stored as float/double.  

---

## 2 answers

### Answer by username_1 on 2014-02-18. Score: 0 | Accepted answer

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](https://gmplib.org), [Java's BigInterger class](http://docs.oracle.com/javase/6/docs/api/java/math/BigInteger.html).

> **Comments:**
> **username_0**: 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?  
> **username_1**: 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.  
> **username_3**: 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.  
> **username_1**: 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).  
> **username_3**: 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.  

---

### Answer by username_4 on 2014-02-18. Score: 0

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.


---

