Binary number, Bits and Bytes and memory Sen Zhang.

37
Binary number, Bits and Bytes and memory Sen Zhang
  • date post

    19-Dec-2015
  • Category

    Documents

  • view

    223
  • download

    1

Transcript of Binary number, Bits and Bytes and memory Sen Zhang.

Page 1: Binary number, Bits and Bytes and memory Sen Zhang.

Binary number, Bits and Bytesand memory

Sen Zhang

Page 2: Binary number, Bits and Bytes and memory Sen Zhang.

• Number systems– Decimal– Binary– Bits– bytes– Numbers conversion among different systems

Page 3: Binary number, Bits and Bytes and memory Sen Zhang.

Binary to Decimal

• To convert 1011 to its decimal value 1011 (It reads one zero one one in binary number)

= 1000+0+10+1

= (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (1 * 2^0)

= 8 + 0 + 2 + 1

= 11 (it reads eleven in decimal system)

• It is wrong to read 1011 one thousand and eleven, if you know it is a binary number.

Page 4: Binary number, Bits and Bytes and memory Sen Zhang.

Decimal to Binary• Keep dividing the decimal number by 2

• An Example to convert 23710 to binary value 1  1  1  0  1  1  0  1     

237 / 2 = 118    Remainder 1------------------------------------------------------| 118 / 2 = 59 Remainder 0---------------------------------------------------| |59 / 2 = 29 Remainder 1------------------------------------------------| | |29 / 2 = 14 Remainder 1------------------------------------------------| | |14 / 2 = 7 Remainder 0---------------------------------------------| | | |7 / 2 =3 Remainder 1------------------------------------------| | | | |3 / 2 = 1 Remainder 1-----------------------------------| | | | | | |1 / 2 = 0 Remainder 1--------------------------------| | | | | | | |                                         v  v  v  v  v  v  v  v 1  1  1  0  1  1  0  1 In the reversed order to get the result!

The result!

Page 5: Binary number, Bits and Bytes and memory Sen Zhang.

The above two slides should be enough for you to prepare exam.

• However, you should proceed reading the rest of the slides for better understanding to binary system if you are interested in computing technology.

Page 6: Binary number, Bits and Bytes and memory Sen Zhang.

• Number systems– Decimal– Binary– Bits– bytes– Numbers conversion among different systems

Page 7: Binary number, Bits and Bytes and memory Sen Zhang.

• In this lecture, we will discuss bits and bytes, binary and decimal numbers in detail so that you will gain a fundamental understanding to their meanings and what these systems are and how they work.

• To help you understand, let's first review the well known decimal number system.

Page 8: Binary number, Bits and Bytes and memory Sen Zhang.

The Decimal Number System

• The decimal system is the base-10 system that we use every day.

• A number, say 6357, represented in the base-10 system consists of multiple ordered digits. (In other words, digits are normally combined together in groups to create larger numbers.)

• A digit is a single place that can hold numerical values between 0 and 9 (10 different values).

Page 9: Binary number, Bits and Bytes and memory Sen Zhang.

Let us start from an arbitrary decimal number

• For example, 6,357 has four digits.

• It is understood that in the number 6,357, – the 7 is filling the "1s place," – while the 5 is filling the 10s place, – the 3 is filling the 100s place – and the 6 is filling the 1,000s place.

• So you could express 6,357 this way if you want to be explicit:

(6 * 1000) + (3 * 100) + (5 * 10) + (7 * 1) = 6000 + 300 + 50 + 7 = 6357

10^3

Page 10: Binary number, Bits and Bytes and memory Sen Zhang.

Continue ..

• Another way to express it would be to use the concept of powers of 10.

• A specific digit is associated with a specific weight expressed as powers of 10. The first digit (counting from the right) gives 10 to the 0 power, the second digit gives 10 to the 1 power, and so on.

Page 11: Binary number, Bits and Bytes and memory Sen Zhang.

• Exponents are a shorthand way to show how many times a number, called the base, is multiplied times itself. A number with an exponent is said to be "raised to the power" of that exponent.

• Assuming that we are going to represent the concept of "raised to the power of" with the "^" symbol.

• "10 squared“ or 10 to the power of 2 is written as "10^2"

• 10 to the fourth power is denoted 10^4

Page 12: Binary number, Bits and Bytes and memory Sen Zhang.

• Thus, another way to express the previous number is like this: (6 * 10^3) + (3 * 10^2) + (5 * 10^1) + (7 * 10^0)

= 6000 + 300 + 50 + 7

= 6357

Page 13: Binary number, Bits and Bytes and memory Sen Zhang.

• But why do we human beings use 10 based number system?

Page 14: Binary number, Bits and Bytes and memory Sen Zhang.

How to count?

• Fingers and toes? Cuts on trunk?– 11111111111111111111111 (23)– 11111 (five)– 1111111111111111111111111111(28)– 11111111111111111 (17 )

• Number system and calculating system– 1, 2, …5 10, 11, … 23– 23+5=28– 23-5=17

Page 15: Binary number, Bits and Bytes and memory Sen Zhang.

• The most commonly accepted explanation is that our base-10 number system was adopted by our ancestors most likely because we have 10 fingers.

• Interestingly enough, that is why digit in English also means a finger or toe.

Page 16: Binary number, Bits and Bytes and memory Sen Zhang.

• We have reasons to ask a question in our minds: – “If we happened to evolve to have eight

fingers instead, would we probably have a base-8 number system?”

• The answer is probably YES!

Page 17: Binary number, Bits and Bytes and memory Sen Zhang.

Any other number systems?• The good news about number systems is

that it is not the only choice to have 10 different values in a digit.

• Actually, we can have base-anything number systems from a theoretical point of view.

• There are many good reasons to use different bases in different situations. For example, 7 days/week, 12 months/year

Page 18: Binary number, Bits and Bytes and memory Sen Zhang.

A generalized rule

• The following rules apply to base 10 and to any other base number system:– The system of base n requires n different

symbols or values. – The left most digit is the highest-order digit

and represents the most significant digit, while the lowest-order digit is the least significant digit.

– A digit is represented as powers of the system's base.

Page 19: Binary number, Bits and Bytes and memory Sen Zhang.

• Computers happen to operate using the base-2 number system, also known as the binary number system, just like the base-10 number system is known as the decimal number system to human beings.

Page 20: Binary number, Bits and Bytes and memory Sen Zhang.

The fundamental point

• Modern computers use binary number system, in which there are only zeros and ones. (Only two symbols)

• A “bit” to binary is similar a “digit” to a decimal information. (Again, the easiest way to understand bits is to compare them to something you know: digits.)

• A bit has a single binary value, either 0 or 1.

Page 21: Binary number, Bits and Bytes and memory Sen Zhang.

Binary vs. Decimal

• Binary is a base two system which works just like our decimal system.

• Considering the decimal number system, it has a set of values which range from 0 to 9.

• The binary number system is base 2 and therefore requires only two digits, 0 and 1.

Page 22: Binary number, Bits and Bytes and memory Sen Zhang.

The fundamental point

• Binary representation of numbers and other information is the representation which can be understood by computer chips and can be saved in memory.

• It is important to computers because all computer data is ultimately represented by a series of zeros and ones, no matter you realize it or not.

Page 23: Binary number, Bits and Bytes and memory Sen Zhang.
Page 24: Binary number, Bits and Bytes and memory Sen Zhang.

• Since the computer is really made up of tiny switches that can be either OFF or ON, you can look at a binary number as a series of light switches. A 1 represents a switch that is ON, and a 0 means a switch that is OFF.

Page 25: Binary number, Bits and Bytes and memory Sen Zhang.

Bits• The binary number system uses binary

digits (bits) in place of decimal digits.

• A binary number is composed of only 0s and 1s, like this: 1011.

• 1011 has four bits

• How do you figure out what the value of the binary number 1011 is in decimal world?

Page 26: Binary number, Bits and Bytes and memory Sen Zhang.

How does it work?

• As we have shown that our decimal system is based on place or location. That is, the place of each digit decides the value of that digit.

• The binary system works in exactly the same way, except that its place value is based on the number two.

Page 27: Binary number, Bits and Bytes and memory Sen Zhang.

What is the value of the binary number 1011?

• Therefore we have the one's place, the two's place, the four's place, the eight's place, the sixteen's place, and so on. Each place in the number represents two times (2X's) the place to its right.

• An example (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (1 * 2^0) = 8 + 0 + 2 + 1 = 11

Page 28: Binary number, Bits and Bytes and memory Sen Zhang.

decimal to binary• Keep dividing the decimal number by 2

• Ex 2 : 23710     

237 / 2 = 118    Remainder 1------------------------------------------------------| 118 / 2 = 59 Remainder 0---------------------------------------------------| |59 / 2 = 29 Remainder 1------------------------------------------------| | |29 / 2 = 14 Remainder 1------------------------------------------------| | |14 / 2 = 7 Remainder 0---------------------------------------------| | | |7 / 2 =3 Remainder 1------------------------------------------| | | | |3 / 2 = 1 Remainder 1-----------------------------------| | | | | | |1 / 2 = 0 Remainder 1--------------------------------| | | | | | | |                                          v  v  v  v  v  v  v  v 1  1  1  0  1  1  0  1

In the reversed order!

Page 29: Binary number, Bits and Bytes and memory Sen Zhang.

1 bit

1 byte

8 bits

Page 30: Binary number, Bits and Bytes and memory Sen Zhang.

A bit

• A ‘bit’ (from Binary + digIT) is the smallest unit of memory, also the unit of measurement of data information.

Page 31: Binary number, Bits and Bytes and memory Sen Zhang.

Bytes

• Since a single bit holds so little information, bits are rarely seen alone in computers. They are almost always bundled together into 8-bit collections, and these collections are called bytes.

• Bytes, larger units, then are treated as integral units of storage.

Page 32: Binary number, Bits and Bytes and memory Sen Zhang.

• 1 bit

• 1 byte = 8 bits

• 1 kb = 210 bytes = 1024 bytes !=1000

• 1 Mb = 1 k k bytes = 210 * 210 bytes

• 1 G b = 210 * 210 * 210 bytes

• 1 Terab = 210 * 210 * 210 * 210 bytes

Page 33: Binary number, Bits and Bytes and memory Sen Zhang.

Even larger capacity

• 1 petabyte = 210 * 210 * 210 * 210 * 210 bytes (2 to the 50th power )

• 1 exabyte= 260

• 1 zettabyte = 270

• 1 yottabyte = 280

Page 34: Binary number, Bits and Bytes and memory Sen Zhang.

Some interesting facts about what these various-sized bytes can store:

• 1 bit: a binary decision• 1 byte: a character• 5 Megabytes: The complete works of Shakespeare• 2 Gigabytes: 20 meters of shelved books• 10 Terabytes: The printed collection of the US Library of

Congress• 200 Petabytes: All printed material in the whole word.• 5 Exabytes: All words ever spoken by human beings

Page 35: Binary number, Bits and Bytes and memory Sen Zhang.

Memory

• Where to save binary numbers in computer?

• In memory!

• What is memory?

• Memory is a space where you can save binary values, consisting of a sequence of units (counted in bytes).

Page 36: Binary number, Bits and Bytes and memory Sen Zhang.

CPU processes binary number

• The first microprocessor to make it into a home computer was the Intel 8080, a complete 8-bit computer on one chip, introduced in 1974.

Page 37: Binary number, Bits and Bytes and memory Sen Zhang.

END