Binary: Which end is up?

Programming, for all ages and all languages.
Post Reply
User avatar
TheDragon
Member
Member
Posts: 43
Joined: Mon Aug 25, 2008 8:23 pm
Location: Middle of Nowhere

Binary: Which end is up?

Post 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.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Binary: Which end is up?

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Binary: Which end is up?

Post 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.
Every good solution is obvious once you've found it.
CodeCat
Member
Member
Posts: 158
Joined: Tue Sep 23, 2008 1:45 pm
Location: Eindhoven, Netherlands

Re: Binary: Which end is up?

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Binary: Which end is up?

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply