Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that after compiling a software or application, its code is converted into the machine language.

Does a compiled software contain a binary 0 and 1?

What happens after compiling a software? Is the code converted into binary 0 and 1? What actually happens to its source code? How is such a huge amount of 0 and 1 stored in the computer?

share|improve this question
Everything on your computer is all 0's and 1's in the end. Everything. I can't provide you with a proper response at the moment, but see my answer to this question to get more information. In a nutshell, compiling a program turns it into it's low-level (assembly) equivalent code first. – Breakthrough Jul 21 '11 at 17:57
@ Breakthrough as you said " In a nutshell, compiling a program turns it into it's low-level (assembly) equivalent code first. " Does that mean a Program compiled in a High level language like VB, will be converted into assembly equivalent first and After that it will be converted into Binary. – Torpido Jul 21 '11 at 18:08
@Randolf Richardson, it varies with what version of VB you are using - but regardless, VB code is compiled. Also, note that VBA (not VB) is not even compiled, but rather interpreted on-the-fly. Also, object code does contain machine code, but does not contain enough to make a complete executable (that's what linking does). – Breakthrough Jul 21 '11 at 18:46
There really is no simple way of explaining this. I often forget people go to school for years just to scratch the tip of the iceberg known as Computer architecture. . . – surfasb Jul 21 '11 at 23:09
It is not a simple as "compiling skips assembly". Compiling often skips assembly, but some compilers target assembly (usually these are simple little compilers---toys, really---but this is not guaranteed). To pick a huge example: gcc's compilation process passes through assembly (or at least it used to). Usually this is hidden from the user as data is piped from one process to the next, but it happens. – dmckee Jul 22 '11 at 0:17
up vote 7 down vote accepted

Yes. Every piece of information on your computer is a comprised of bits (on PCs it's normally 8 bits per byte, and some systems define bytes as having a different number of bits). Although, source code, technically, is stored in binary form, a variety of approaches and methods can be used to identify it as "text."

Binary is the notation used to describe the base-2 representation of the data (1s and 0s). This document explains this notation in great detail, and will probably be of interest to you:

  Binary code

After compilation, the resulting binary data usually represents a sequence of instructions (a.k.a., sequences of byte codes) that the processor understands and acts on accordingly. There are a large number of instructions that perform mathematical operations, modify memory contents, communicate with peripherals, and deal with a number of other things.

A high-level language like C, Pascal, Perl, etc., can be compiled into binary code which is then run directly by the CPU, and this binary code is most commonly referred to "machine language."

Assembler source code (which is not considered a "high-level language") is the form of source code that is closest to machine language, but also needs to be compiled to binary code for the CPU to process it correctly.

When interpreted code is run (such as with a script), it is being compiled on-the-fly by an interpreter as each line or section is encountered, and tends to run much slower than binary code as a result. BASIC (such as GW-BASIC from the DOS days in the 1980s and early 1990s), although not known as a scripting language, was also interpreted (including the loops -- there was no caching, every line was continually re-interpreted).

share|improve this answer

Everything on a computer is a collection of bytes. Since bytes are a set number (usually 8) of ones and zeros, indeed everything in a computer is ones and zeroes.

A program is a stream of instructions.

CPU's work by fetching bytes from RAM and performing an action based on the value of that byte. A stream of such bytes forms a program. Bytes in this context are called opcodes and represent elementary operations.

Compiling is a multi-stage process that essentially "converts" or "translates" source code text into a stream of opcodes. Nothing happens to the original source code.

Compilers are themselves programs whose job is to read through source code text and make the conversion to machine language. Central to the operation of any compiler is a concept called a parser that scans each character (byte) of each line of text, separates it into words and operators (i.e., tokens), and figures out based on the the presence and order of specific words what machine language opcodes to generate.

Programs rarely execute from start to finish. Usually decisions (i.e. conditional statements) are made based on data gathered by the program and the program might skip (a.k.a. jump or branch) to different sections of itself. Alternatively sections of the programs might be written as subroutines or functions and might be reused or called throughout the program. Because of this most compilers have to make two passes or more through the source code to figure out where all the "jumps" end up to. This is called linking.

Huge numbers of zeroes and ones are able to be stored mainly because of advances in chip manufacturing technology, and the fact that a CPU can access an amount of RAM that is 2 to the power of the number of address lines it has. A 32-bit CPU usually has at least 32 address lines, so thats 2^32 or 4Gbytes of RAM. Memory wasn't always this cheap or plentiful. Ads for computers in the late 70's/early 80's show that RAM was $500 or more for 4Kbytes, and even more expensive the earlier you go.

share|improve this answer
+1 especially for that trip down memory lane with RAM prices. – Randolf Richardson Jul 22 '11 at 1:11
No no no, the answer to how do I store lots of 0s and 1s is by having lots of memory is incorrect. A Computers dose not store 01010011 as 8 characters but as 1 byte, well actually that depends, because it this case it did store it as 8 characters. But in the case of a character being represented as 8 '1s` and 0s, it is not stored as a sequence of 8 characters (1s and 0s) that are then each encoded in to 1s and 0s, this would be infinite recursion. No it is stored in a byte of 8 bits a bit can be represented as a 1 or 0 but is not a 1 or 0 it is an electrical charge. – richard Sep 28 '12 at 9:05

As other answers said, yes, computers store and handle data and instructions BINARY, so they, or better, their most basic elements (transistors etc.) compute with two states, On/Off, Low/High, or 0 and 1.

But there are (or were) other methods! There are analog computers, the opposite of DIGITAL computers, where digital means that you can point out DISCREET and specific values (digit <-> finger). In analog computers, you can not, there are no values of a distinct nature, everything is something in between (as in whole numbers and real numbers). But there's no "program" which gets compiled to machine code. There are mechanical/electronic elements which determine the "program"

More interesting: There are DIGITAL computers that are not operating binary but TERNARY:

In these computers there are THREE states, -1/0/1. And there're even programs which get compiled to a machine code. So, concluding: Maybe. Compiled software may also contain three digital identifiers, -1, 0 and 1 ;)

share|improve this answer
A base-3 representation (most likely using the digits 0, 1, and 2) would need to be used for ternary since -1 would be awkward to represent where more than one bit was concerned. I also suspect that these tri-state bits could also create some interesting strategies for compression algorithms. – Randolf Richardson Jul 22 '11 at 1:04

While the answer yes is correct, the answer no is more correct.

The information is stored (as has already been said) in electrical charges: on and off or maybe positive and negative or high and low or low and high, and some systems used current instead of charge. But in summary there are two electrical states.

To make things easier people abstracted this to 0 and 1, that way they did not need to know how the hardware did it and the code was more portable.

Later more layers of abstraction where added: assembler, character codes (ASCII etc), then …


if (a==b)

may becomes

ld r1 a
ld r0 b
cmp r1,r0
br.z %endif1

Now you may hear that cmp r1,r2 is converted to 0110110111001010, but this is not exactly correct. Because 0110110111001010 is a sequence of 16 characters (at least 16 bytes uncompressed) that represents 2 bytes of data. But is it wrong to say this? Well only in the same way that me saying that I had spaghetti for dinner is wrong. I did not have a sequence of characters s p a g h e t t i for dinner. I can not show you what I had. I can show a picture, but I did not eat a picture. So remember the 0s and 1s are just a representation of what is really happening. And when I say I see 1 moon in the sky, this 1 represents something completely different. And when I say beware that the characters 1 and l and the characters 0 and O, can be confused these 1s and 0s are again a different thing.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .