# Elementary binary question

**URL:** <https://boards.straightdope.com/t/elementary-binary-question/343190>\
**Category:** Factual Questions\
**Created:** [February 6, 2006, 5:02am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190 "2006-02-06T05:02:15Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leibowitz](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@Leibowitz](https://boards.straightdope.com/u/Leibowitz)\
**Post date:** [February 6, 2006, 5:02am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/1 "2006-02-06T05:02:15Z")

</div>

So I was trying to make a joke with my son about binary (admittedly an error on my part) and then I got confused. Does the binary sequence go 0, 1, 00, 01, 10, 11 or does it go 0, 1, 10, 11, 100, 101, 110, 111??? In other words, can binary use leading zeros? I am pretty sure the proper sequence is the second one but I am not sure why. I know we don’t use leading zeros. Are binary zeros exactly the same as decimal zeros?

---

<div class="post-metadata">

**Author:** ![OldGuy](https://avatars.discourse-cdn.com/v4/letter/o/3bc359/32.png) [@OldGuy](https://boards.straightdope.com/u/OldGuy)\
**Post date:** [February 6, 2006, 5:05am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/2 "2006-02-06T05:05:22Z")

</div>

> [@Leibowitz](#):
>
> So I was trying to make a joke with my son about binary (admittedly an error on my part) and then I got confused. Does the binary sequence go 0, 1, 00, 01, 10, 11 or does it go 0, 1, 10, 11, 100, 101, 110, 111??? In other words, can binary use leading zeros? I am pretty sure the proper sequence is the second one but I am not sure why. I know we don’t use leading zeros. Are binary zeros exactly the same as decimal zeros?

Yes. It would use leading zeroes only in the same case we would decimally. For example if there was a counter with a certain number of dials all set to zero originally like the odometer on a car.

The second sequence is correct.

---

<div class="post-metadata">

**Author:** ![Patty\_O\_Furniture](https://avatars.discourse-cdn.com/v4/letter/p/96bed5/32.png) [@Patty\_O\_Furniture](https://boards.straightdope.com/u/Patty_O_Furniture)\
**Post date:** [February 6, 2006, 5:10am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/3 "2006-02-06T05:10:41Z")

</div>

Leading zeros are important in [BCD format](http://en.wikipedia.org/wiki/Binary-coded_decimal).

---

<div class="post-metadata">

**Author:** ![Cunctator](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@Cunctator](https://boards.straightdope.com/u/Cunctator)\
**Post date:** [February 6, 2006, 5:15am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/4 "2006-02-06T05:15:28Z")

</div>

> [@Leibowitz](#):
>
> I am pretty sure the proper sequence is the second one but I am not sure why.

As \*\*OldGuy \*\* has said, the second sequence is correct. Each digit in binary represents a multiple of 2[sup]0[/sup], 2[sup]1[/sup], 2[sup]2[/sup] etc in the same way that they represent 10[sup]0[/sup], 10[sup]1[/sup], 10[sup]2[/sup] etc in decimal.

So 111 in binary  
= (1 x 2[sup]2[/sup]) + (1 x 2[sup]1[/sup]) + (1 x 2[sup]0[/sup])  
= 4 + 2 + 1  
= 7

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [February 6, 2006, 5:26am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/5 "2006-02-06T05:26:27Z")

</div>

Like others have said, leading zeroes behave just like you would expect them to in decimal. There’s a bit of a wrinkle, though, because computers operate in binary and they can’t deal with variable length numbers. To the computer I’m typing this on right now, every number consists of 32 digits. Leading zeroes are just a fact of life here.

---

<div class="post-metadata">

**Author:** ![gazpacho](https://avatars.discourse-cdn.com/v4/letter/g/6f9a4e/32.png) [@gazpacho](https://boards.straightdope.com/u/gazpacho)\
**Post date:** [February 6, 2006, 5:30am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/6 "2006-02-06T05:30:46Z")

</div>

Does anyone use BCD anymore?

Most hardware that does signed arithmatic uses 2s compliment representation for the numbers. 2s compliment representation uses n bits to encode -(2^n) to (2^n -1). The nth bit is valued at -(2^n). So if you want to count natural numbers you can omit the leading zeros but if the value can be negative then leading zeros matter.

Is 111 7 or is it -1?

---

<div class="post-metadata">

**Author:** ![Arjuna34](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Arjuna34](https://boards.straightdope.com/u/Arjuna34)\
**Post date:** [February 6, 2006, 5:31am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/7 "2006-02-06T05:31:53Z")

</div>

You do use leading zeros for “floating point” binary numbers:

on the left side of the “binary point”, each digit is worth 2[sup]0[/sup], 2[sup]1[/sup], as **Cunctator** said. On the right side, each digit is worth 2[sup]-1[/sup], 2[sup]-2[/sup], etc.

For example,

0.5 = 0.1  
0.75 = 0.11  
0.125 = 0.001

3.14159 = 11.0010010000110…

For numbers with a binary point, the leading zeros matter just like with decimal numbers.

Arjuna34

PS - lets not get into whether 1.0 = 0.1111111… binary!

---

<div class="post-metadata">

**Author:** ![Voyager](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/voyager/32/133_2.png) [@Voyager](https://boards.straightdope.com/u/Voyager)\
**Post date:** [February 6, 2006, 5:32am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/8 "2006-02-06T05:32:43Z")

</div>

Binary per se does not have to use leading 0s, so your second choice is correct. If you are representing the contents of storage of a certain size (which does not have to be the native word size of a computer) then you would use leading 0s. And not just for binary - hex also.

A 32 bit binary word of

0000000111111010  
would be  
01fa in hex.  
Same for octal, and any other base you’d choose.

---

<div class="post-metadata">

**Author:** ![Bryan\_Ekers](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bryan_ekers/32/183_2.png) [@Bryan\_Ekers](https://boards.straightdope.com/u/Bryan_Ekers)\
**Post date:** [February 6, 2006, 5:37am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/9 "2006-02-06T05:37:34Z")

</div>

Incidentally, “121” in any number base (bigger than binary, of course) is a perfect square, representing as it does: x[sup]2[/sup] + 2x + 1 = (x+1)[sup]2[/sup].

Thus, in decimal, 121 = 11[sup]2[/sup]  
Hexadecimal 121 = 289 decimal = 17[sup]2[/sup]  
Octal 121 = 81 decimal = 9[sup]2[/sup] and so forth.

1331 is always a cube, too.

---

<div class="post-metadata">

**Author:** ![Nanoda](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@Nanoda](https://boards.straightdope.com/u/Nanoda)\
**Post date:** [February 6, 2006, 5:55am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/10 "2006-02-06T05:55:10Z")

</div>

If it interests you much, you can get a [binary clock](http://www.thinkgeek.com/interests/binary/59e0/). Coincidentally, the place where I work just hired a new employee, and he brought one of these to work last week.

---

<div class="post-metadata">

**Author:** ![TJdude825](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@TJdude825](https://boards.straightdope.com/u/TJdude825)\
**Post date:** [February 6, 2006, 7:38am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/11 "2006-02-06T07:38:54Z")

</div>

> [@gazpacho](#):
>
> Does anyone use BCD anymore?

Yes. For example:

> [@Nanoda](#):
>
> If it interests you much, you can get a [binary clock](http://www.thinkgeek.com/interests/binary/59e0/).

Internally, within a computer, you mean? Probably not much.

---

<div class="post-metadata">

**Author:** ![mks57](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@mks57](https://boards.straightdope.com/u/mks57)\
**Post date:** [February 6, 2006, 8:29am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/12 "2006-02-06T08:29:06Z")

</div>

> [@gazpacho](#):
>
> Does anyone use BCD anymore?

Yes. Most handheld calculators use BCD arithmetic. It’s also widely used in business applications and hardware-constrained systems that display/print numbers.

Mike Cowlishaw from IBM is probably the world’s top expert on decimal arithmetic. See [http://www2.hursley.ibm.com/decimal/](http://www2.hursley.ibm.com/decimal/) for everything you ever wanted to know about decimal arithmetic.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [February 6, 2006, 9:26pm UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/13 "2006-02-06T21:26:12Z")

</div>

Quoth **Bryan Eckers** :

> [@](#):
>
> Incidentally, “121” in any number base (bigger than binary, of course) is a perfect square, representing as it does: x[sup]2[/sup] + 2x + 1 = (x+1)[sup]2[/sup].
> 
> Thus, in decimal, 121 = 11[sup]2[/sup]  
> Hexadecimal 121 = 289 decimal = 17[sup]2[/sup]  
> Octal 121 = 81 decimal = 9[sup]2[/sup] and so forth.
> 
> 1331 is always a cube, too.

More to the point, 121 = 11[sup]2[/sup] and 1331 = 11[sup]3[/sup] in every bases where those numbers are defined. 121(hex) = 289(dec), and 11(hex) = 17(dec). It’s also true that 100 = 10[sup]2[/sup] in every base, 14641 = 11[sup]4[/sup], and 15aa51 = 11[sup]5[/sup].

---

<div class="post-metadata">

**Author:** ![chrisk](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@chrisk](https://boards.straightdope.com/u/chrisk)\
**Post date:** [February 7, 2006, 12:01am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/14 "2006-02-07T00:01:45Z")

</div>

> [@Chronos](#):
>
> More to the point, 121 = 11[sup]2[/sup] and 1331 = 11[sup]3[/sup] in every bases where those numbers are defined. 121(hex) = 289(dec), and 11(hex) = 17(dec). It’s also true that 100 = 10[sup]2[/sup] in every base, 14641 = 11[sup]4[/sup], and 15aa51 = 11[sup]5[/sup].

And pascal’s triangle strikes again. 😉

---

<div class="post-metadata">

**Author:** ![panache45](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/panache45/32/64_2.png) [@panache45](https://boards.straightdope.com/u/panache45)\
**Post date:** [February 7, 2006, 12:55am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/15 "2006-02-07T00:55:50Z")

</div>

> [@Leibowitz](#):
>
> Does the binary sequence go 0, 1, 00, 01, 10, 11 . . .?

Quite aside from the leading-zeroes question, how could “00” ever follow “1”?

---

<div class="post-metadata">

**Author:** ![Cabbage](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@Cabbage](https://boards.straightdope.com/u/Cabbage)\
**Post date:** [February 7, 2006, 1:04am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/16 "2006-02-07T01:04:02Z")

</div>

> [@panache45](#):
>
> Quite aside from the leading-zeroes question, how could “00” ever follow “1”?

It’s not how binary works, but I see what **Leibowitz** was thinking. 00 follows 1 because 1 is the largest single binary digit, while 00 is the smallest string of two binary digits.

In other words, in this ordering we first have the single digits:

0  
1

Then we have the binary strings with two digits:

00  
01  
10  
11

Three digits:

000  
001  
010  
011  
100  
101  
110  
111

Next come all the four digit sequences, and so on.

It’s a well-defined order on the set of all finite strings of binary digits, but it’s not the standard one.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [February 7, 2006, 1:05am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/17 "2006-02-07T01:05:52Z")

</div>

Not standard for arithmetic, perhaps, but that sort of ordering is very convenient in proofs that certain sets (notably, the set of finite-length binary strings) are countable.

---

<div class="post-metadata">

**Author:** ![iamthewalrus\_3](https://avatars.discourse-cdn.com/v4/letter/i/258eb7/32.png) [@iamthewalrus\_3](https://boards.straightdope.com/u/iamthewalrus_3)\
**Post date:** [February 7, 2006, 1:24am UTC](https://boards.straightdope.com/t/elementary-binary-question/343190/18 "2006-02-07T01:24:30Z")

</div>

> [@Cabbage](#):
>
> It’s a well-defined order on the set of all finite strings of binary digits, but it’s not the standard one.

To be pedantic, that’s because the "standard"one isn’t really an order on the set of finite binary strings, it’s an order on the set of nonnegative integers. Which happen to be expressed in binary notation.
