금융 경제 보험 정보

binary number system in computer science 본문

카테고리 없음

binary number system in computer science

정보캣 2023. 11. 3. 09:16

how do we atcually communicate with computer?
when we make a basic code to print out 'Hello World', how does computer understand this code?

writing codes means speaking order to computer to do something. that's why we called some programining languages like C, python and Java as a language
so it's same with learing engilsh and learning codes in some context like as I am a Korean, to talk with American, I have to lean English and as I am a human, to talk with a computer I have to learn C, Java, Swfit and so on.

so If I wanna make computer to display a images, first I need to write code and then compilor translating this codes into compiled language which is understood by a computer. and then this compliled langue can be a machine language that computer actually read and do something.


the machine language use the binarny number system. but we human beings use decimal system. for the human, the deciaml system using 10 digit is more comfortable. as we have 10 fingers, when we count something, we use 10 fingers. for example, if there are 10 black pigs, we can count the numbers of pigs by folding the fingers.

however computers only use 2 digit as 1 or zero. because under the lowest level where computer is opereated, an electrical signal is used. The only change made by an electricity is either turn on or turn off.

so when electicity is turn off, it's called as zero, and when electicity is turn on, it's called as one. that's why the computer use bynaray number system.

okay and let's started for how to caculate binary number syterm
for better understanding, let's think about deciaml number system

when we read 5432 under the deciaml number system,
we can separate each number unit as thousand, hundred, ten and zero
so it could be 5000 + 400 + 30 + 2
and the 2 is multipying 10 to the power of zero =2
the thirty is 3 multipying 10 to the power of one =3 x 10 = 30
the four hunderd is 4 mulitplying 10 to the power of two = 4X100 = 400
the five thousand is 5 muliplying 10 to the power of three = 5 x 1000 = 5000

this is how to caculate decimal system

but for the binary system, there are only 0 and 1 so it looks like

binary , decimal
0 = 0
1 = 1
2 = 10
3 = 11
4 = 100
5 = 101
6 = 110
7 = 111
8 = 1000
9 = 1001
10 = 1010

when you wanna translate bynary number to decimal number, it's same as we seperating deciaml number before but just change unit from ten to two

for example
'1001010 (2)'

we can seperate as

The 0 is multiplying 2 to the power of zero = 0 x 2^0 = 0
The 1 is multiplying 2 to the power of one = 1 X 2^1 = 2
The 0 is multiplying 2 to the power of two =0 x 2^2 = 0
The 1 is multiplying 2 to the power of three = 1 x 2^3 = 8
The 0 is multiplying 2 to the power of four =0 x 2^4 = 0
The 0 is multiplying 2 to the power of five =0 x 2^5 = 0
The 1 is multiplying 2 to the power of six = 1 x 2^6 = 64

The sum of these results should be: 0 + 2 + 0 + 8 + 0 + 0 + 64 = 74








 

Comments