PDA

View Full Version : Why do computers use binary?



DumbleDoor
10-30-2009, 07:41 PM
Exactly the title. Wouldn't it be easier to have them use something like base 1 million?

Evil Knievel
10-30-2009, 08:15 PM
because there are only 2 states: current on and current off.

its built-in.

fazisi
10-30-2009, 10:52 PM
Because computers are dumb.

Nate
10-31-2009, 12:44 AM
Your question seems to be focused on why computers don't operate in a higher base than 2. Let's consider for a moment how it is that computers can perform pre-programmed logical operations:

1) Mathematicians realized long ago that it is useful to apply binary partitioning to all sorts of concepts to facilitate thinking about them. By "binary partitioning" I mean dividing a set into members that do and members that do not have some particular property. For instance, mathematicians might say that there are two kinds of people in the world: those who like math and those who don't.

For instance: The set S consists of Jack, John and Ryan. The property is liking math. Jack likes math. John likes math. Ryan does not like math. So, the set can be partitioned into two subsets based on the property: The set L of Jack and John (who like math) and the set N of Ryan (who does not like math)

2) Mathematicians noticed that there are some relationships that can be distinguished from each other between pairs of members of a set that can be partitioned in such a fashion. For instance, the "and" relationship applies to a pair of set members when both members of the set have the property.

For instance: in terms of the liking math property, the "and" relationship applies to the pair "Jack and John" because Jack AND John like math (that is, because Jack likes math AND John likes math).

Another such relationship is the "xor" relationship. The "xor" relationship applies to a pair of set members when one member has the property and the other member does not.

If we were to discuss for a moment the pair of "Jack and Ryan" we could say that Jack XOR Ryan like math. This would still be true if suddenly Jack did not like math but Ryan did.

Another: the "equals" relationship. This is another relationship that would apply to "Jack and John" because they either both have or both do not have the property (in this case both have).

3) Mathematicians then found it useful to apply the concept of "testing" a pair for various different relationships.

For instance, they can test "Jack and John", "Jack and Ryan" or "John and "Ryan" each to see if the "and" relationship applies in terms of the "liking math" property.

Jack and John: AND applies.
Jack and Ryan: AND does not apply
John and Ryan: AND does not apply.

Or another test for the "xor" relationship:

Jack and John: XOR does not apply
Jack and Ryan: XOR applies
John and Ryan: XOR applies

4) Next comes the concept of chaining together these tests. What if you really need to know whether or not a set of three people all like math? Based on a simple twist in our pairwise logic, you can test the first two members for the "and" relationship regarding liking math, then you can test the third member against the result of the first test. To illustrate:

S is the set containing Jack, John and Ryan. Jack and John like math, Ryan does not. First test Jack and John for the AND relationship:

Jack AND John like math, since Jack likes math and John likes math.

Now you get to define a new set, S'. S' is the set containing "Jack and John" and Ryan. That's right, it contains an aggregation of the two members of the initial pair!

Test the two members of S' and you have your answer regarding S:

"Jack and John" AND Ryan don't like math, since Ryan doesn't like math.

5) So, based on a simple binary relationship we can create complicated tests and interconnect them logically to understand various things. So why not create even more complex tests based on ternary relationships to understand even more complicated things?

The answer is simple. Binary partitioning covers everything! I can divide S very easily into those who do and those who do not like math. It is impossible due to the nature of the partition I chose to find any member of S who does not fall into one of its partitions. Aggregation of binary logic allows pairwise relationships to be applied to more complicated input sets than just pairs.

That shows that binary is sufficient, but it doesn't show that binary is necessary. Why not divide the world into those who like math a lot, a little bit or not at all? That would give us a ternary partition that would allow us to define pairwise relationships and we already know about aggregating pairwise relationships to represent bigger input sets.

The answer is that there is consistently a way of creating a binary partition based on members of a set having or not having a property thanks to negation. What would be a consistent way of partitioning a set into three partitions rather than two? I cannot think of one. If there is one, it is probably abstractly related to some essential ternary concept just as binary partitioning is abstractly related to negation (which is essentially binary). If you think of one that is more useful than binary partitioning, please let the world know about it!!!

6) Electronics give us a simple way of representing a binary partition. Electronic components are partitioned into those with an active voltage level running through them and those without an active voltage level running through them. Furthermore, electronic gates give us a simple way of representing the various relationships between pairs of binary inputs.

I'm not going to actually diagram a computer because it's less interesting, but I think this is a pretty solid explanation of why computers use binary logic.

7) In case the question gets confused with the notion of register size, I will address that for a moment:

We all know that the old 8-bit NES was awesome. But then the 16-bit SNES was even more powerful after that, suggesting that a higher bit count may be somehow intrinsically better. Is this related to binary computers versus base-1000 or whathaveyou computers?

No. Consider for a moment your long term memory, your short term memory and your awareness of your present surroundings. Long term memory is like a computer's hard drive space. Short term memory is like a computer's RAM. Your present awareness is like your computers CPU where the bit counts apply. Those bit counts apply to how much your computer can be thinking about at any given time and increasing them is generally a good thing when your computer needs to be thinking bigger, deeper thoughts.

None of this has anything to do with whether it is appropriate for a computer to be thinking in terms of pairwise relationships between members of a set that was partitioned in two based on a property.

Any other questions?
________
Marijuana vaporizer (http://vaporizer.org/)

gut
10-31-2009, 08:33 AM
I studdied all this junk forever ago (~12 years), and
asked myself the exact same question. There are many
different answers. I know that hard drives don't actually
store info as binary. They have different wave patterns
that represent ones and zeros.

Modern solid state electronics definitely have the ability
to recognize more than just on's and off's. That may have
been the original reason for binary use, but I think it is
more than that now. Honestly, I'd say an entire industry
has been built around binary, and no one wants to put
the effort into rethinking everything from the ground up.

DumbleDoor
10-31-2009, 05:49 PM
Nate, what if you have something that is three groups. There are Jack, John, and Ryan. John likes binary. Jack is neutral towards binary. Ryan dislikes binary. What is the point of binary then?

Zeno
11-01-2009, 02:01 PM
Humans started counting with just showing a number of I's: I, II, III, IIII, ... up to 4, because without learning how to count, it would be difficult for them to tell difference between IIIII and IIIIII. Thus, they have started to using a special sign for 5 (V, like a full hand). Any yet another special signs for 10 (X, two full hands). The same system was used consistenly for larger numbers: XXXXX = L, LL = C, CCCCC = D, and so on. (I use the Roman numerals, but IIRC actually it was before Romans and they used something different.) And thus the decimal system was born.

But actually I think binary is more logical even for humans. (Binary itself is of course impractical because it leads to very long numbers. But hexadecimal and octal systems combine the terseness of decimal with the doubling philosophy of binary.)

In music there are notes of length 1/2, 1/4, 1/8, ..., 1/64th of the full note. Why not 1/100th? Because the rhythm is naturally about doubles and halves. You are much more likely to hear powers of 2 in music than powers of 10. Somehow it is easier to compose a bigger part of melody from two smaller parts, than from 3 or 10.

In the US system of coins and banknotes (for example) you have 1 Cent, 2, 5, 10, 25, 50, $1, $2, $5, $10, $20, $50, $100. Why not 1$, 2$, 3$, 4$, 5$, 6$, 7$, 8$, 9$? Again, doubles and halves, except they had to be adjusted to the decimal system, since it would be difficult to count the money otherwise. If humans used a binary (or octal, or hexadecimal) system, the coins would be just powers of two, and the foreigners in US would not be confused with this two-digit quarterdollar.

Some of the early computers (e.g. ENIAC) used decimal system, but it turned out to be a bad idea. A transistor naturally works in binary (either there is power on input or not; it will produce power on its output only if there is power on input A but no power on input B). You can encode a single ternary digit with two bits (transistors or binary digits), or a single decimal with 4 bits, but such circuits would be much more complicated than the usual binary ones. It's better to perform all the calculations in binary and use decimal only for human input and output.

In your example of three people: it is true that the binary system is less efficient at expressing trichotomies (3 possibilities) than ternary (only 79% power of the two binary digits is used, while ternary of course uses 100%; the 79% value is for the trivial encoding with two bits, simple Huffman encoding (if possible) uses 95% power). But ternary is even worse at expressing dichotomies (2 possibilities): only 63% power of the ternary digit is used, and dichotomies are also much more common than trichotomies. Binary is not the best for everything in particular, but it is the best in general.

DumbleDoor
11-01-2009, 02:14 PM
Humans started counting with just showing a number of I's: I, II, III, IIII, ... up to 4, because without learning how to count, it would be difficult for them to tell difference between IIIII and IIIIII. Thus, they have started to using a special sign for 5 (V, like a full hand). Any yet another special signs for 10 (X, two full hands). The same system was used consistenly for larger numbers: XXXXX = L, LL = C, CCCCC = D, and so on. (I use the Roman numerals, but IIRC actually it was before Romans and they used something different.) And thus the decimal system was born.

But actually I think binary is more logical even for humans. (Binary itself is of course impractical because it leads to very long numbers. But hexadecimal and octal systems combine the terseness of decimal with the doubling philosophy of binary.)

In music there are notes of length 1/2, 1/4, 1/8, ..., 1/64th of the full note. Why not 1/100th? Because the rhythm is naturally about doubles and halves. You are much more likely to hear powers of 2 in music than powers of 10. Somehow it is easier to compose a bigger part of melody from two smaller parts, than from 3 or 10.

In the US system of coins and banknotes (for example) you have 1 Cent, 2, 5, 10, 25, 50, $1, $2, $5, $10, $20, $50, $100. Why not 1$, 2$, 3$, 4$, 5$, 6$, 7$, 8$, 9$? Again, doubles and halves, except they had to be adjusted to the decimal system, since it would be difficult to count the money otherwise. If humans used a binary (or octal, or hexadecimal) system, the coins would be just powers of two, and the foreigners in US would not be confused with this two-digit quarterdollar.

Some of the early computers (e.g. ENIAC) used decimal system, but it turned out to be a bad idea. A transistor naturally works in binary (either there is power on input or not; it will produce power on its output only if there is power on input A but no power on input B). You can encode a single ternary digit with two bits (transistors or binary digits), or a single decimal with 4 bits, but such circuits would be much more complicated than the usual binary ones. It's better to perform all the calculations in binary and use decimal only for human input and output.

In your example of three people: it is true that the binary system is less efficient at expressing trichotomies (3 possibilities) than ternary (only 79% power of the two binary digits is used, while ternary of course uses 100%; the 79% value is without simple Huffman encoding, which makes it more effective at 95%). But ternary is even worse at expressing dichotomies (2 possibilities): only 63% power of the ternary digit is used, and dichotomies are also much more common than trichotomies. Binary is not the best for everything in particular, but it is the best in general.
OK, thank you, ZENO! What do you know, Zeno saved the day! But what about calculators... Do they use binary?

Zeno
11-01-2009, 03:38 PM
The tradeoff between binary and decimal is that binary is more natural for electronics, but requires some work to translate to/from decimal. Sometimes, when I had to do (quite simple) calculations on a computer using very large numbers, I did them in base 1000000000 (numbers in this base are straightforwardly translated to base 10 which I wanted my output to use, and 32-bit processors are designed to add numbers smaller than 2^31 = 2147483648 with a single operation). So, I suppose that for simple calculators which can do only + - * /, performing calculations in decimal might be actually more practical, while for the complicated ones, binary is better. But these are only my guesses.

Nobbse
11-02-2009, 04:08 PM
There are other possibilities to store and work with information, indeed,
you can have a look at

http://en.wikipedia.org/wiki/Analog_computer

http://en.wikipedia.org/wiki/Binary-coded_decimal
(still it is based on binary)

but the most efficient and fundamental base is the binary system.

Pumpernickel
11-03-2009, 09:21 PM
In music there are notes of length 1/2, 1/4, 1/8, ..., 1/64th of the full note. Why not 1/100th? Because the rhythm is naturally about doubles and halves.


Not exclusively - three-based rhythms also exist, as do trioles. 5- and higher-based rhythms tend to be composites of terniary and binary rhythms, though.

Money:


Again, doubles and halves, except they had to be adjusted to the decimal system, since it would be difficult to count the money otherwise.


Depends on which alternative system you use - many european currencies used e.g. duodecimal systems until the late 19th century, the UK even until 1970 or so. Duodecimal is pretty versatile really, as you can easily produce not only halves, but also thirds and quarters, which don't really work out with a pure base 10 (and give the slightly odd 25 for quarters when you go centesimal instead of pure decimal).

Zeno
11-03-2009, 11:18 PM
Not exclusively - three-based rhythms also exist, as do trioles. 5- and higher-based rhythms tend to be composites of terniary and binary rhythms, though.


I am not an expert in musical rhythms, I know that the notes have lengths 1/2^n-th (and also 3/2^n-th), but I am not so sure about the part about rhythms, I did not do (any read about) any real analysis. A piece I had in mind is Vivaldi's Winter, lots of powers of two can be heard there, but one example proves nothing. (5-based rhythm as a composite of 2 and 3, is that some kind of a Fibonacci sequence?)


Depends on which alternative system you use - many european currencies used e.g. duodecimal systems until the late 19th century, the UK even until 1970 or so. Duodecimal is pretty versatile really, as you can easily produce not only halves, but also thirds and quarters, which don't really work out with a pure base 10 (and give the slightly odd 25 for quarters when you go centesimal instead of pure decimal).

Yeah, duodecimal is a very nice system. I think both duodecimal and hexadecimal would be more practical than decimal. (Among them, I think that duodecimal was better before the era of computers, as it allows easy division by 3 (much more useful than easy division by 5), but hexadecimal would be better nowadays as it is the native language of computers.) Too late to change anyway ;)

Pumpernickel
11-03-2009, 11:56 PM
(5-based rhythm as a composite of 2 and 3, is that some kind of a Fibonacci sequence?)

No, there are pieces in 5/4 time (quite rare, but they exist), where each measure has a primary stress on the first and a secondary on the third or fourth, making the whole more of a 3+2 rhythm than a straight five-rhythm. Similarly in 7/8 and 8/8, you usually get something that's closer to a 3+4 or 3+3+2. Shifting rhythm was quite common for centuries, and is still somewhat common e.g. in gypsy music.

Sorry, but i can't express it very clearly in english, especially when limited to writing. Let it suffice that i find there's more to musical rhythm than binary, although quite a lot of it _does_ work that way. A bit like there's no requirement for a digital computer to work in binary, although most of them do, and for good reasons.

DumbleDoor
11-04-2009, 12:47 AM
In Zeno's thing, what does the n-th stand for?

Zeno
11-04-2009, 08:03 AM
I meant "1 divided by (n-th power of two)"-th.