Fathers’ Day is coming up…
I’ll have the kids get you a calculator. They’re $1 at Wal-Mart.
There are 10 types of people on this planet.
Those who understand binary, and those who don’t…
-jjg
DailyScoff.com
I guess there’s 100 of us that can appreciate that abacus (and I’m assuming that Nick’s one of them).
This is roughly how digital chips work with their logic “gates” for computations.
Except your using electrical on and off voltages at the “input and output lines.
So I have a question for the computer/math types.
How does a computer know the difference between a numerical value and a character.
For example the character n is 01101110
But 01101110 also = 110
How does a computer recognize the difference?
>How does a computer recognize the difference?
Context.
Oh well theres a great explanation Jason… So enlightening
How does a computer recognize the difference?
When a computer stores a character it actually uses “O” and “I” in place of 0 and 1, as you might also see on a license plate. They look the same to the untrained eye.
XXPilot,
Jason is essentially correct. It is context.
Text editors, for example attempt to translate the data into text characters and if the data contains encodings outside normal text ranges you see gobbledygook. There are editors out there that if you so choose render all data in its raw binary form (a sometimes helpful thing to do). Typically they contain the datastream in hexadecimal (0123456789ABCDEF 10 11 12 13…) display on one side and display the text on the other side of the display, or in the case of ISPF you just type “hex on” and the hex representation of the data in binary appears.
Open up a GIF image file using notepad.
On the computer systems I have worked on there is no real way to look at a file or a dataset and determine if they are pure text files or binary files. Extensions on windows/dos systems are arbitrary and do not guarantee anything. You need to read the file and if it contains data that can be translated into text using standard encoding schemes (ASCII is one EBCDIC another, there are more) then it is text, otherwise it is binary data and may or may not represent numbers.
Aside from that the only real difference is in how much space it takes to store each one. Typically a character is stored in one byte (allowing for 256 different characters) and numbers (of various types) are stored in some multiple of that. However, things vary from language to language and platform to platform.
Numbers themselves may be stored in files in various ways. The COBOL I am used to can store numbers in three ways, display (using text digits) or it can encode the numbers in other schemes that make better use of storage space or are better for computations.