Page 1 of 1

Binary: Which end is up?

Posted: Sat Oct 25, 2008 11:51 pm
by TheDragon
Hello. I'm trying to start some tutorials or something like that and I was going to explain the basic fundamentals in the very beginning because my teaching philosophy is that one should never leave anything out, so of course I want to explain binary. I know what binary is, and I am also experienced in the field of electronics/robotics, but I have no idea what the representation for binary digits is, say, on a hard drive. Is 1 a negative charge or is 0 a negative charge? It is natural to say 0 has a negative charge and 1 a positive, and, after all, weren't computers invented back when electricity flowed from the possitive terminal to the negative? This is all so confusing. Please help me.

Thank you.

Re: Binary: Which end is up?

Posted: Sun Oct 26, 2008 2:34 am
by Brendan
Hi,
TheDragon wrote:Hello. I'm trying to start some tutorials or something like that and I was going to explain the basic fundamentals in the very beginning because my teaching philosophy is that one should never leave anything out, so of course I want to explain binary. I know what binary is, and I am also experienced in the field of electronics/robotics, but I have no idea what the representation for binary digits is, say, on a hard drive. Is 1 a negative charge or is 0 a negative charge? It is natural to say 0 has a negative charge and 1 a positive, and, after all, weren't computers invented back when electricity flowed from the possitive terminal to the negative? This is all so confusing. Please help me.
A bit has 2 states. The value 0 might be a positive charge, a negative charge, the present of any change, the absence of any charge, the presence of a specific frequency, the absence of a specific frequency, etc. On storage media it may be a magnetic field or difference in optical properties. For a switch or relay it might be a short or an open. In some cases, groups of bits might even be encoded as something entirely different. For example, you might have something with 4 states used to store pairs of bits, where binary 00 is state 0, binary 01 is state 1, binary 10 is state 2, and binary 11 is state 3 - maybe 0v, 0.7v, 1.4v and 2.1v; or maybe you might have 8 specific frequencies, where the value of an entire byte is represented by the presence or absence of each of these frequencies.

The point I'm making here is that as programmers we don't really care - we only see set (1) and clear (0), regardless of what representation these states have in the underlying hardware.

For a tutorial, you could ignore reality (or more accurately, ignore the set of all possible realities) and instead describe a conceptual/simplified model of the hardware. For example, describe a theoretical machine where +5v is '1' and 0v is '0'...


Cheers,

Brendan

Re: Binary: Which end is up?

Posted: Sun Oct 26, 2008 5:17 am
by Solar
TheDragon wrote:...I have no idea what the representation for binary digits is, say, on a hard drive. Is 1 a negative charge or is 0 a negative charge?
On a hard drive, it's magnetic fields, not electic charge.

Re: Binary: Which end is up?

Posted: Sun Oct 26, 2008 5:19 am
by CodeCat
For media like hard discs, AFAIK usually the bits are stored not in the presence or absence of magnetic fields, but in the transition between them. I.e. the transition from low to high is a 1, from high to low is a 0. The reason for that is a matter of physics: a rapidly changing magnetic field induces strong currents, where the direction of change determines the current direction. The read head can therefore simply use the direction of current to determine what bit was read, which is easier to detect than if the bits were determined by the presence or absence of a field.

Re: Binary: Which end is up?

Posted: Mon Oct 27, 2008 4:11 am
by Combuster
And not all bits on storage media are data: CDs use 8-to-14 encoding schemes, where redundant information is stored to keep the reader on track, and single errors won't cause a different byte to be read.
Some harddisks also use synchronized encodings to keep the reader in speed with the disk itself, which again means that change (or absence thereof) doesn't always imply a bit in the output data.