16

I have done some searching but have not found a truly satisfactory answer. As a developer i want to invest the necessary time in understanding this, thus i am looking for a complete explanation on this and feel free to provide any useful references.

Thanks.

amosrivera
  • 26,114
  • 9
  • 67
  • 76
  • 1
    I think because the digital signal can take the input either `1` or `0`. – Mahesh Mar 02 '11 at 08:25
  • 5
    possible dublicate [Why binary and not ternary computing?](http://stackoverflow.com/questions/764439/why-binary-and-not-ternary-computing) – Nick Dandoulakis Mar 02 '11 at 08:29
  • See the question linked to by user Nick D - ternary computers also existed but haven't become common. – sharptooth Mar 02 '11 at 08:31
  • Thanks, but the question linked above is far more specific and concerning whether or no to use a different base, it is not what i'm looking for. – amosrivera Mar 02 '11 at 08:42
  • the binary system has something to do with that, or so i have heard, if you believe otherwise please feel free to retag, you sure have enough reputation for that. – amosrivera Mar 02 '11 at 14:40
  • 5
    Given the answers below, I would say computer programmers in general are not the people to ask about hardware design or electronics – BlueRaja - Danny Pflughoeft Mar 03 '11 at 00:07
  • @Blue You're quite right. Perhaps the ultimate reason is that analog computers DO exist. – Dr. belisarius Mar 04 '11 at 02:29
  • All about transistors... they are ON or OFF, aka 1 or 0.... this is the world of digital and silicon. You'll notice that analog machines in our world have no on or off, and therefore there's no loss of "resolution" - however this is significant degradation of analog media. – Shackrock Jul 28 '11 at 02:02

10 Answers10

18

I would recommend buying this book by Andrew S. Tanenbaum. He developed one of the predecessors to Linux called Minix. I used Structured Computer Organization as part of my university course.

Why computers use binary is not just a matter of switch context.

Relative to a reference voltage of say 3v. +1v(4v) = true or 1 and -1v(2v) = false or 0.

It also has to do with the most efficient method of creating controlling or logic circuits. This has to do with cost of implementation. How much does it cost to build circuits that work with binary compared to circuits that work with decimal or analogue see this answer.

If you compare how many billions of binary circuit transistors fit on to a modern CPU. The cost of doing that with say decimal (or analogue) system increases exponentially for every digit you want to add as you now have to add that much more controlling circuitry.

If you want to understand some of the most important contributing components that have helped to make binary the default standard for logic and controlling circuitry read and understand the following topics from Wikipedia. It will take about 4 hours to read through the most important topics, which have to do with some of the electrical engineering used to create the circuits.

I tried to be complete in this list of concepts you need to understand how the actual switches work and why they are used. As well as why Binary Arithmetic is such an efficient form of computation in hardware.

  • Transistor types Understand the pnp and npn transistor types to understand how the actual circuity that forms the switches works. These circuits are very cheap to make and can be shrunk to minuscule(nano meter) size
  • Logic Circuitry. If you understand the basic logic circuitry you will understand how the actual transistor types are used to implement them. These relate to some of the programming constructs such as "and &&" "or ||" and "if, branch" constructs.
  • DigitalCircuitry has a use full disadvantages section comparing analog and digital circuits
  • NAND Logic Gate is important as all other logic gate circuits can be implemented using just this one logic gate. Simplifying the manufacturing process, as the complexity of the machinery used to create the the circuits can be streamlined.
  • Adder Circuits To understand how basic addition is done using logic gates.
  • Twos Complement this is very help full in understand number representation in actual CPUs. It is also very cheap to implement this type of arithmetic in a CPU, as it requires fewer transistors. For instance a simple addition circuitry is all that is need to do addition and subtraction. If you add a negative number you get the correct answer ie +7 + (-4) = +3. This also helps to understand the integer overflow
  • Binary_number
  • These are some of the most used circus for controlling other circuits. These control when circuits are switched on and off. Decoder Encoder How (if or branch) condition logic is implemented.
  • Multiplexer Is fundamental to how routing is done. In a CPU, BUS and in a network. One of the most common logic circuits found in most digital devices.

Now for some hard cores stuff. C. and C++ is used to write device drivers that speak to actual hardware. If you really want to get into how certain devices work, your CPU, and or external devices learn Assembler. You will begin to see how you can switch off a device by setting a certain device register to a specific value, that will be read by a logic circuit to change the devices state. For example you will understand why (0101) base2 = 5 (binary related stuff) will route a specific way through the circuits to switch the device on and off.

Community
  • 1
  • 1
nelaaro
  • 3,006
  • 5
  • 38
  • 56
  • 1
    Sorry will update once i have a higher reputation, with the links I wanted to include. I had a nice eplanation, but too many links. – nelaaro Mar 02 '11 at 11:50
  • This answer made me lol - Tanenbaum wrote a very popular book on the basics of hardware design, but that one (though also very popular) is not it. I think you were thinking of [Structured Computer Organization](http://www.amazon.com/Structured-Computer-Organization-Andrew-Tanenbaum/dp/0131485210/ref=sr_1_1?ie=UTF8&qid=1299110510&sr=8-1). – BlueRaja - Danny Pflughoeft Mar 03 '11 at 00:03
  • @blueraja-danny-pflughoeft Thanks for the correction, I should have check before putting down the link – nelaaro Mar 04 '11 at 13:01
  • @blueraja-danny-pflughoeft I see that your on of the guys that voted to close this as of topic. but __the faq shows on point 4__ **that are unique to the programming profession.** I think this is in the c++ or assembler programing domain and considering that all we do is work with computer I feel this is very relevant, hence the up votes and views. – nelaaro Mar 04 '11 at 13:20
  • @nelaar Close voters are not notified by `@-replies`, but as far as I can tell, *nothing* in the question says anything C++ or assembler programming. Your answer might mention those, but it's the *question* we're talking about, not answers – Yi Jiang Mar 07 '11 at 11:44
  • @yi-jiang how should I contact them. I don't see any way to do it. any help would be nice – nelaaro Mar 08 '11 at 08:03
14

Computers could have been built to work even with decimal numbers, but from the engineering point of view it is a lot safer to distinguish only two states.

The voltage of the value 1 (+5V) is only a theoretical value, in real-life it always differs a bit. Would have they done computers with decimals, there would be no way to tell if +4.75V is 9 or 10.

pestaa
  • 4,749
  • 2
  • 23
  • 32
  • 3
    +1. That's better, I've been waiting for this one - it is indeed because of the ease of distinguishing voltages - electronics buffs know this because of the propensity to treat "on" as anywhere between 3.5 and 5V for instance and off below 1.5V. It's all down to practicality - even the much vaunted square wave is not square but just an approximation. – paxdiablo Mar 02 '11 at 08:52
  • 1
    Then there are really old systems based on relays rather than transistors (think old pinball machines). Those really are ON or OFF. – phkahler Mar 02 '11 at 16:31
  • @phkahler: +1, that is exactly what I was going to add. – BlueRaja - Danny Pflughoeft Mar 03 '11 at 00:09
  • @paxdiablo yes but we use hysteresis. – stefan Mar 19 '11 at 01:47
2

It is because how logic gates work: There is a logical output (1) if the control voltage exceeds a certain threshold; no logical output (0) if not.

But probably much more crucial:

Maybe one time computers wouldn't work in binary anymore when quantum based machines arise (or other stuff like that, which maybe would encourage more complex state representations). But as binary values are the simplest possible representation of any (more complex) state, even in "quantum times" it probably would be most appropriate to stay with computers working in binary (abstracting from other physical representations like ternary or so, if given).

Flinsch
  • 4,296
  • 1
  • 20
  • 29
2

Stumbled upon this question. I recommend two books which addresses the question faithfully:
A Peek at Computer Electronics: Things you Should Know - by Caleb Tennis
CODE : The Hidden Language of Computer Hardware and Software - by Charles Petzold

And if you really want to understand how computers work, then take up:
The Elements of Computing Systems: Building a Modern Computer from First Principles
-By Noam Nisan and Shimon Schocken

Aby James
  • 23
  • 5
1

Computers are using electricity as a mean to transport informations. And the easiest way to use electricity as an information is as On or Off (1 or 0).

Sure you can use different voltage to represents different number, but the electronic components to do so are really complicated.

It is also important to note that the ability to write and read 1 and 0 are enough to compute any calculation, this is called Turing completeness, so there is no need to find some more complex systems allowing something else than binary

(Ok, to be thorough, Turing completeness can be achieved only with infinite memory, but this isn't really relevant here.)

krtek
  • 26,334
  • 5
  • 56
  • 84
0

Well in computers we always go with things with least complexity that helps us speed up computations. So here if we see binary is the least complex of them all..

Consider the number 1000 here,

For Unary :- Input Symbols {0} No of digits to represent 1000 :- 1000, Complexity :- 1000*1=1000

For Binary :- Input Symbols {0,1} No of digits to represent 1000 :- 10, Complexity :- 10*2=20

For Ternary :- Input Symbols {0,1,2} No of digits to represent 1000 :- 7, Complexity :- 7*3=21

For Decimal :- Input Symbols {0,1,2...9} No of digits to represent 1000 :- 4, Complexity :- 4*10=40

Thus we see binary has the least complexity.

0

Well I guess u need to consider the IC's within a PC, each IC has millions of Gates mostly NANDS or NORS and every computation is either a true or a false i.e. 0 or 1 respectively and thus binary number would suffice. Hope it's clear :-)

NirmalGeo
  • 773
  • 4
  • 12
0

Ok... I will give you my opinion about it, but first It's necesary to say that I'm far for being an expert, so take my answer carefully.

In the bottom of all this hardware, gates and transistors, a computer It's no more that a circuit. In every part of a circuit, the electric pulses can flow... or not flow (this is a simplified version, read paxdiablo comment). 2 states. This two states can be represented by a 0 or a 1. And that's binary!

In fact, maths calcs can be made in every base, the only reason because the human being use base-10 is that we (use to) have 10 fingers so it's easy to understand by us. The digital systems has two states, so the base-2 is the best choice for them.

Jonathan
  • 11,809
  • 5
  • 57
  • 91
  • 1
    theoretically it is possible to have more than one state. You can play with the voltage, for example 0v = 0, 1v = 1, 2v = 2 etc. But it is way more complicated. – krtek Mar 02 '11 at 08:33
  • 1
    Actually, it's high and low _voltage_ rather than current flow but I'm more interested in your assertion that we _used_ to have ten fingers. Are you living in a mutant colony or something? :-) – paxdiablo Mar 02 '11 at 08:39
  • 3
    @paxdiablo: :D Yes, we are cultivated in little cubicles and they made us develop software 10 hours a day. Some genetic experiments has been done to create a new race with more fingers that will be able to develop faster. – Jonathan Mar 02 '11 at 08:45
-1

Because computers are state machines and they understand mainly two states. That is, on and off and it concerns electricity. That is the main reason.

Also, how else would you find tshirts saying that there are 10 types of people, those who understand binary and those who do not ? :)

Spyros
  • 46,820
  • 25
  • 86
  • 129
  • 1
    Thats like saying you have 50% chance to win lottery; either you win or not. Also, its completely wrong. – stefan Mar 02 '11 at 08:29
  • sure it's wrong if you say so, lol. They also understand the state of non existing electricity in other universes, that represents 2. – Spyros Mar 02 '11 at 08:32
  • 2
    SpyrosP: We have simply defined 1/0 to specifiv Volt-levels, its no matter defining more levels to have more basic number representation. For machines we often use alot more than 1/0, actually the most common sollution is to use a continus signal ie having infinite many states. – stefan Mar 02 '11 at 08:39
  • i thought i mention electricity in my reply. should i say circuits to make it better ? – Spyros Mar 02 '11 at 08:46
-1

Computers basically work on electric signals; as a dumb machine , it can only understand 'high' and 'low' . High is +5v and low is 0v. (v-volt). Thus , the 1 in binary represents high or 'on' . 0 represents 'low' or 'off'. So, binary is needed to make computer understand something.

  • High and low are not actually always tied to 5v and 0v. Quite apart from the fact that 0v/5v is just one possible representation (RS232, for example used +/- 12V from memory), sometimes they're inverted. – paxdiablo Mar 02 '11 at 08:47