hi, i have been wondering, after the compilation of a textual source file, it is said that it is compiled to ones and zeros, i wonder what are those ones are zeros, are they visible to eyes? for example if i open it with notepad can i display them? if i can not ever display them then in what sense(if not visual) are they ones and zeros. Thank you.

I can't decide if this is a joke or not. Anyway, the easiest way to look at the machine code (what people typically mean when they talk about "ones and zeros") is with a hex editor. Some hex editors even give you a binary view.

Regardless if this is a joke or not, zeros and ones don't exist! IMHO A hard disk stores levels of "magnetism" which correspond to levels of "voltage" (mostly 0 and 5 volts) When a computer "reads" this is what you could call a "bitstream". It depends on the programmer how this is displayed... 0V level could be displayed as 0, x, hoebahoeba or whatever. Same for 5V. By convention we call them 0 and 1, plus it it handy in binary calculations.

I can't decide if this is a joke or not. Anyway, the easiest way to look at the machine code (what people typically mean when they talk about "ones and zeros") is with a hex editor. Some hex editors even give you a binary view.

this is not a joke, i create executables with GNU gcc compiler, when i open that executable with notepad i dont see zeros and ones but i do see some absurd set of characters. why do i see them?

Regardless if this is a joke or not, zeros and ones don't exist! IMHO A hard disk stores levels of "magnetism" which correspond to levels of "voltage" (mostly 0 and 5 volts) When a computer "reads" this is what you could call a "bitstream". It depends on the programmer how this is displayed... 0V level could be displayed as 0, x, hoebahoeba or whatever. Same for 5V. By convention we call them 0 and 1, plus it it handy in binary calculations.

i agree with you, there is no concrete one and zeros, i dont have a computer science background, that is why i felt the need to ask such a question.

Believe me there are no "dumb" questions, there are only "dumb" answers...
The reason you see strange characters on a screen is that "zeros" and "ones" are translated to ASCII on a screen or terminal. So if the bitpattern at hand translates to an 'A' you will see an A on your screen, else you might see something that looks like gibberish...

Believe me there are no "dumb" questions, there are only "dumb" answers...
The reason you see strange characters on a screen is that "zeros" and "ones" are translated to ASCII on a screen or terminal. So if the bitpattern at hand translates to an 'A' you will see an A on your screen, else you might see something that looks like gibberish...

thanks man, i have been wondering this for four years, thank you so much!!

this is not a joke, i create executables with GNU gcc compiler, when i open that executable with notepad i dont see zeros and ones but i do see some absurd set of characters. why do i see them?

You don't see them because "1" and "0" are just the symbols we have given to binary numbers. We could have called them "alphas" and "betas" or anything else instead. Asking what a 1 or 0 is physically is like asking what the numbers of the decimal system are physically. In a computer system though, they are typically voltages. The reason the binary system is used, is because it isn't as easy to design electronic devices that work with 10 different voltage levels as it ones which use 2. Each memory cell of RAM contains a capacitor which is either charged or discharged for example. But using the binary system they can represent any quantity that can represented in decimal, or any of the other number systems.

ok, thank you for your explanations but then i would like to see bit patterns with some tools. let say i open an executable with that tool and i see something like this 10110100100101001 and so on.
if you are good enough, show me an example like this :) (this sounds like a challenge although it is not)

You need a hex editor as mentioned, like
http://www.softcircuits.com/cygnus/fe/
You just convert the hexadecimal bytes to binary in your head.

what is the reason for the editor to display hex but not bin? how it is useful?

what is the reason for the editor to display hex but not bin? how it is useful?

Which would you rather call out over the phone, a long string of binary numbers or a short string of hexadecimal numbers?

Which would you rather call out over the phone, a long string of binary numbers or a short string of hexadecimal numbers?

understood!
thanks.

It's all about perception and interpretation.

Think of the world of software as being entirely virtual. Said slightly differently, a physical representation of software is simply a translation to that medium. If you print your C source code on paper, you are translating your source code to ink on paper; no computer can compile what's on that paper. If you store your C source code on disk, it has been translated to one of many different kinds of encoding schemes that can be stored and retrieved; but a compiler cannot compile this, either.

A computer's most basic piece of information is a binary digit--a zero or a one--because binary digits are fairly trivial to depict using electronics. However, a long string of Binary digITS (bits) is all but incomprehensible. Early computer people developed octal (base 8) and hexadecimal (base 16) representations of binary information because it's easier for humans to deal with. Binary programs are typically stored on disk and in memory as groups of 8 bits (bytes, octets).

Not long after that, they realized they needed a standard way to represent text and other things. So they created EBCDIC (Extended Binary Coded Decimal Interchange Code) and ASCII (American Standard Code for Information Interchange). These are 8-bit representations of information that both humans and information display devices can understand. Included are the numbers (0-9), letters (A-Z and a-z), punctuation and special characters (like @, #, $, {, ], et al), and device control characters (carriage return, line feed, form feed, vertical tab, start-of-text, end-of-transmission, bell). In the years since then, more information was stuffed into the 8 bits and character sets were expanded to include multi-byte characters.

(Still with me? It won't belong now....)

So, programs are stored as 8-bit bytes. Human-readable information is stored as 8-bit bytes. Computers are dumb. They don't (necessarily) know human text from binary. If you load a text file into memory and try to execute it, it will fail gloriously. And quickly. If you load a binary file into a human-oriented text editor, it will obey and display the information as best as it can. It won't mean much to a human, though.

Why don't you see binary? Because the text editor is designed to present human-readable info. It hasn't been designed to translate binary info into human-readable binary digits.

If you really had your heart set on seeing binary, you would have had to either write a program to translate binary data into a text file consisting of the human-readable characters '0' and '1' or use an old computer that has a front panel (binary switches and lights).

Did any of this make any sense?

:) :)

:) :)

yeah i understood it totally, thank you.

The characters you see are translated from the binary code. You could copy that text and translate it to binary...
http://www.paulschou.com/tools/xlate/
..and you'll get 8 digits of binary. For example, A is 01000001

You don't see them because "1" and "0" are just the symbols we have given to binary numbers. We could have called them "alphas" and "betas" or anything else instead. Asking what a 1 or 0 is physically is like asking what the numbers of the decimal system are physically.

You're right, they're abstract objects and they can only be observed through the mind - as opposed to physical objects which are sometimes visible.

binary is just another number system that can be used to display a set of the same data.

a "c" can be displayed as the decimal (base 10 number system, 0 to 9) 99,
or as a hex value (base 15 number system, 0 to 9, A to F) 63
or as a binary value (base 2 number system, 0 to 1) 01100011
c = 99 = 63 = 01100011 it's all the same piece of data.

0     0     0000
1     1     0001
2     2     0010
3     3     0011
4     4     0100
5     5     0101
6     6     0110
7     7     0111
8     8     1000
9     9     1001
10    A     1010
11    B     1011
12    C     1100
13    D     1101
14    E     1110
15    F     1111

notepad is a text editing program, so it displays the data of a file using the character values of each byte of data. So when you open an executable file, you see a whole bunch of gibberish, because the data in the executable isn't meant to be displayed as characters and words but they are meant to be instructions--your processor can treat all the data on your hard drive and in your memory as executable code or data, it's all the same-certain bytes represent certain processor instructions but they also have a character value if they are supposed to be data. Make sense? A hex editor is meant to display the hexadecimal value of the data that it reads so that is exactly what it does. Some hex editors will let you see the binary value of the data as well. Binary doesn't really have a purpose that you will see very often though, really just in processor mathematics, shift operations, etc. if you are dealing with binary code you are usually dealing with it in its hexadecimal form.

the opcode (or machine code) to move the hexadecimal value "0123" into the AX processor register is B82301. It's easier to view it as the assembly mnemonic "mov ax,0123" but if you were to actually deal with that instruction in binary, you would see 101110000010001100000001
not very appealing


in short, everything in your computer is "ones and zeros" just there are different systems for displaying them so it's not very often that the data in your computer is viewed in actual binary.

although i marked this as solved, people seem to be very enthusiastic about adding to this thread. :) thanks for your responses. I understood.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.