• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

another binary question?


OSNN Senior Addict
if i have a bit pattern such as ... 0101 001

can the computer tell if its a number, character or an instruction, if so how?

you may want to look into machine language (assembly). you actually enter in binary values. it's a super fast language, but pretty dang hard to code in.

just googlize "machine language" or "assembly language". :)


Debiant by way of Ubuntu
computers would not be able to tell from a simple bit pattern - and these days eight bits would not be enough for them to deduce anything much - it is all context sensistive.

(I am still programming in assembler, so I have some idea!)

In basic terms - a computer keeps a place marker for where it is up to in memory - typically known perhaps as a Program Status Word (PSW). From there it may look forward to see if it has an instruction code during execution, and each different instruction code will have different formats which the computer (or rather the Operating System) will recognise.

Whenever a computer tries to execute something that is NOT an instruction you will know about it pretty soon - the program will be highly unlikely to get much further!

Usually in machine language you are only patching - if you want to code close to the metal you best bet is assembler which allows mnemonics - so that I can write B for a branch instead of coding x'47F0address'. Then better yet you have macros on top - so that you can wrap up common constructs as you require them.... Keep going like that and you'll write a language perhaps!
The "computer" can't tell diddly about what the bit pattern represents. It just does things to 1' and 0's.

The programming language keeps track of what each group of 1/0's are for. The language can be assembly (lowest level programming language, close to the 1/0's in the machine), Basic, Pascal, C (and dozens of others that are dead or dying).

Each language handles the characters, numbers, strings (of letters) a little differently so when looking at the 1/0's you need to have an idea of what language the code was written in.

Sometime you can open the program file in notepad and see strings of text (these are in ascii text format that is a standard across all compuer languages). Never save a program file you open with any kind of word processor!!!!!! It may be corrupted.

Ascii uses 8 bit data groups allowing 256 characters. The first 128 are well defined (numbers, letters, punctuation and some control characters that go back to the old teletype terminals) and the last 128 can vary with the application. Note The ascii charaters do not correspond directly to anything. i.e. 0 is not 0, etc.

And to answer your question the programming language has a compiler and linker that change the instructions you write into machine instructions, text, numeric data, etc and put it all in a format the machine can read and execute.

Some of the new web pseudo languages like HTML, JAVA, etc use interpreters that take the programming instructions directly or precompile them into an intermediate language (used to be called pseudo code) that is easier for machines to use. In this case each machine must have the final compiler installed on it so it can take the code on the fly and interpret it. This kind of compiling is inherently slower but allows for compatibility between machines (same web pages runs (almost) the same way in IE, Netscape or on a Mac)

Well that ought to keep you busy till the turkeys done ;)
Originally posted by LeeJend

The "computer" can't tell diddly about what the bit pattern represents. It just does things to 1' and 0's.
actually, if you really want to get technical, computers don't even understand numbers...

only if a transistor is "on" (we represent that as the number 1) or "off" (we represent that as the number 0). :p


Political User
Wow, this thread is full of new stuff to learn, we hear what Machine Assembler Language is, we learn that computers only have transisters that can go on and off.

If you have a binary sequence like you showed, it can represent anything.

It can be 0101 001b which could then be put into hexadecimal, decimal, and any other base.

0101 001 is meaningless without specifying anything. If used in a C++ program, you can use it to manipulate other numbers, or do bitwise operations with it. If used in a sentence, it would just be a few characters, and not a lot more, which would then be represented in the memory by:

8x lenght of string.
i'm not sure about using binary in a c++ program. i went to a tech school and took a couple of years of programming classes, including c++, and never encountered using binary with it per se. we did however, have to learn binary and hexidecimal in c programming. i think it was more of a logic test than anything else.

i think binary numbers are mainly used with assembly language. i've never taken a class on assembly, but i've heard it's extremely difficult.

c++ is a higher programming language, meaning that it's easier for people to program in it, than say machine language (the lowest programming language because it's the closest thing you can get to direct instructions to the computer).

Members online

No members online now.

Latest posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member