<p>Not that other answers are wrong here, but just to approach your confusion from another angle:</p>

<blockquote>
  <p>SHA256 hashing algorithm, which produces alphanumeric hashes.</p>
</blockquote>

<p>That's not true. The hashing algorithm produces a stream of bytes. Only when you display that bunch of bytes on your screen it's common for it to be in hexadecimal (containing "alphanumeric" characters A to F) but that's just for display purposes to make it human-readable.</p>

<p>You may as well display that same bytes as a large decimal number (requires more screen space and doesn't have the advantage that each two digits represent exactly one byte from the original. Or you could display it in binary: 256 zeroes and ones.</p>

<blockquote>
  <p>My question is, how can one alphanumeric hash output be "less than" another?</p>
</blockquote>

<p>Even disregarding the above, what stops you from sorting a list of words alphabetically? One word will be "less than" another word.</p>

CC BY-SA 3.0
2016-07-17T02:33:00.623Z
RE: your question at the end: I thought of that, the difference is that hashes contain numbers and letters, whereas words are letters-only.  Take a case of two single-digit alphanumeric strings.  Is "5" greater or less than "b"?  I wasn't aware until now that hashes are hexadecimal (not alphanumeric); this fact answers my question.
Richie Thomas
CC BY-SA 3.0
2016-07-17T11:44:33.183Z
@toomanyrichies It's less. Use the order `0123456789abcdef` (case insensitive) when sorting hexadecimal alphabetically.
wizzwizz4
CC BY-SA 3.0
2016-07-17T02:23:18.133Z
2016-07-17T02:23:18.133Z
Jannes
<p>You treat the hash as a base 16 number, and compare it like you would an integer. </p>

<p>So, for example, with normal numbers, to determine that 926 is less than 941, you basically follow this reasoning: </p>

<ol>
<li>The numbers have the same number of digits, so nothing can be determined yet. </li>
<li>The numbers both have a 9 in the 100s place, so nothing can be determined yet. </li>
<li>926 has a 2 in the 10s place, where 941 had a 4, so 926 is less. </li>
<li>The rest of the digits don't matter. </li>
</ol>

<p>With SHA256 hashes, it's basically the same algorithm (conceptually), you just have to include a-f in the numbers. So, if we have two hashes 1a2cf... and 1b67e..., the first is smaller, because the second digit 'a' (which is 10 in normal numeric notation) is less than 'b' (which is 11 in normal numeric notation). </p>

CC BY-SA 3.0
2016-07-17T01:30:36.253Z
2016-07-17T01:30:36.253Z
morsecoder
<p>Those are numbers written in hexadecimal (or base 16) as opposed to decimal (base 10) which you are used to.
Decimal uses 0-9 giving 10 independent numerals. So 12 in decimal is written as '12'.
Hexadecimal uses 0-9 and a-f in addition giving 16 independent numerals so decimal 12 in hexadecimal is 'c'.</p>

CC BY-SA 3.0
2016-07-17T01:26:12.557Z
2016-07-23T10:44:28.003Z
2016-07-23T10:44:28.003Z
Pandalover
<p>The hash is not alphanumeric, it's hexadecimal, that is base-16. You can convert that to a decimal number. In your case:</p>

<p>0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 = 102987336249554097029535212322581322789799900648198034993379397001115665086549</p>

<p>The actual bytes are actually base-256 (8 bits to a byte), but it's relatively easy to represent the base-256 string in hexadecimal.</p>

CC BY-SA 3.0
2016-07-17T01:24:57.043Z
2016-07-17T01:24:57.043Z
Jimmy Song
<p>I was under the impression that Bitcoin's method for validating a hash involved making sure the hash started with a pre-determined number of zeroes.  However, after reading the docs <a href="https://bitcoin.org/en/developer-guide#proof-of-work" rel="nofollow">here</a>, I see the following sentence:</p>

<blockquote>
  <p>To prove you did some extra work to create a block, you must create a
  hash of the block header which does not exceed a certain value.  To
  prove you did some extra work to create a block, you must create a
  hash of the block header which does not exceed a certain value. For
  example, if the maximum possible hash value is 2^256 − 1, you can prove
  that you tried up to two combinations by producing a hash value less
  than 2^255.</p>
</blockquote>

<p>This is confusing to me, since according to my research the Bitcoin protocol uses the SHA256 hashing algorithm, which produces alphanumeric hashes.  For instance, when I hash an empty file named "foobar.txt", I get "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855".</p>

<p>My question is, how can one alphanumeric hash output be "less than" another?</p>

CC BY-SA 3.0
2016-07-17T03:24:32.450Z
You are confusing values with representations of values. That sequence of characters is not a value, it's a representation of a value.
David Schwartz
<hash><proof-of-work><sha256>
If SHA256 produces an alphanumeric hash, how can a hash be "less than a certain value"?
Richie Thomas
# If SHA256 produces an alphanumeric hash, how can a hash be "less than a certain value"?

(Asked by: username_0 on 2016-07-16)

I was under the impression that Bitcoin's method for validating a hash involved making sure the hash started with a pre-determined number of zeroes. However, after reading the docs [here](https://bitcoin.org/en/developer-guide#proof-of-work), I see the following sentence:

> To prove you did some extra work to create a block, you must create a
> hash of the block header which does not exceed a certain value. To
> prove you did some extra work to create a block, you must create a
> hash of the block header which does not exceed a certain value. For
> example, if the maximum possible hash value is 2^256 − 1, you can prove
> that you tried up to two combinations by producing a hash value less
> than 2^255.

This is confusing to me, since according to my research the Bitcoin protocol uses the SHA256 hashing algorithm, which produces alphanumeric hashes. For instance, when I hash an empty file named "foobar.txt", I get "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855".

My question is, how can one alphanumeric hash output be "less than" another?

**Tags:** hash, proof-of-work, sha256

> **Comments:**
> **username_1**: You are confusing values with representations of values. That sequence of characters is not a value, it's a representation of a value.  

---

## 4 answers

### Answer by username_6 on 2016-07-17. Score: 6 | Accepted answer

The hash is not alphanumeric, it's hexadecimal, that is base-16. You can convert that to a decimal number. In your case:

0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 = 102987336249554097029535212322581322789799900648198034993379397001115665086549

The actual bytes are actually base-256 (8 bits to a byte), but it's relatively easy to represent the base-256 string in hexadecimal.


---

### Answer by username_2 on 2016-07-17. Score: 9

Not that other answers are wrong here, but just to approach your confusion from another angle:

> SHA256 hashing algorithm, which produces alphanumeric hashes.

That's not true. The hashing algorithm produces a stream of bytes. Only when you display that bunch of bytes on your screen it's common for it to be in hexadecimal (containing "alphanumeric" characters A to F) but that's just for display purposes to make it human-readable.

You may as well display that same bytes as a large decimal number (requires more screen space and doesn't have the advantage that each two digits represent exactly one byte from the original. Or you could display it in binary: 256 zeroes and ones.

> My question is, how can one alphanumeric hash output be "less than" another?

Even disregarding the above, what stops you from sorting a list of words alphabetically? One word will be "less than" another word.

> **Comments:**
> **username_0**: RE: your question at the end: I thought of that, the difference is that hashes contain numbers and letters, whereas words are letters-only.  Take a case of two single-digit alphanumeric strings.  Is "5" greater or less than "b"?  I wasn't aware until now that hashes are hexadecimal (not alphanumeric); this fact answers my question.  
> **username_3**: @toomanyrichies It's less. Use the order `0123456789abcdef` (case insensitive) when sorting hexadecimal alphabetically.  

---

### Answer by username_4 on 2016-07-17. Score: 4

You treat the hash as a base 16 number, and compare it like you would an integer.

So, for example, with normal numbers, to determine that 926 is less than 941, you basically follow this reasoning:

1. The numbers have the same number of digits, so nothing can be determined yet.
2. The numbers both have a 9 in the 100s place, so nothing can be determined yet.
3. 926 has a 2 in the 10s place, where 941 had a 4, so 926 is less.
4. The rest of the digits don't matter.

With SHA256 hashes, it's basically the same algorithm (conceptually), you just have to include a-f in the numbers. So, if we have two hashes 1a2cf... and 1b67e..., the first is smaller, because the second digit 'a' (which is 10 in normal numeric notation) is less than 'b' (which is 11 in normal numeric notation).


---

### Answer by username_5 on 2016-07-17. Score: 1

Those are numbers written in hexadecimal (or base 16) as opposed to decimal (base 10) which you are used to.
Decimal uses 0-9 giving 10 independent numerals. So 12 in decimal is written as '12'.
Hexadecimal uses 0-9 and a-f in addition giving 16 independent numerals so decimal 12 in hexadecimal is 'c'.


---

