Download presentation
Presentation is loading. Please wait.
Published byConstance Hunter Modified over 8 years ago
1
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP 2610 1
2
The Bit as the Unit of Information At the underlying level, we let the electrons and the volts be a value, either on or off This is cheaper and simplier than have a circuit who can detect 118.3 volts versus 120 volts We let 1 represent the presence of voltage and 0 as the absence of voltage
3
The Bit as the Unit of Information We refer to each 1 or 0 as a bit, which is the short form of binary digit For the decimal system, there are 10: 0,1,2,3,4,5,6,7,8,9 For the binary system, there are two values 0 and 1
4
The Bit as the Unit of Information More precisely, we only detect voltage from 0 and far from zero So, if we had a range of 0 to 2.9 volts, 2.6 might be 1, and 0.2 might be regarded as 0
5
The Bit as the Unit of Information In order to represent larger quantities, we use a combination of bits Many times, we combine 8 bits for one particular value That gives us 2 8 =256 different values In general, k bits allows for 2 k different values
6
Data Types We can represent values in a number of different ways For example, we can represent 5 by holding 5 fingers up In binary, this might be written as 11111 This notation is called unary
7
Data Types The Romans had their own value as well: V There is a final representation that we will use: 00000101 We use this form since we have to manipulate the values in addition to representing them
8
Data Types We say a representation is a data type if there are operations in the computer that can manipulate this representation There are two basic data types: – ASCII code – used for characters on the keyboard – 2's complement integers – used for positive and negative integers
9
Data Types There are other data types For example, there is scientific notation: 3.4 x10 -4 The data type on the computer for this is called floating point
10
Unsigned Integers We first consider the unsigned integers as a data type We use this for counting and memory addresses We use a positional notation for the binary representation
11
Unsigned Integers To understand positional notation in general, consider the decimal number 583 We know that 5 stands for 500, 8 for 80 and 3 for 3 That is, – 583 = 5*100 + 8*10 + 3*1
12
Unsigned Integers Or, in scientific form, – 583=5x10 2 + 8x10 1 + 3x10 0 Now, the binary form works the same, so the number 6 is – 6 = 00110 = 0x2 4 + 0x2 3 + 1x2 2 + 1x2 1 +0x2 0 For k bits, we can represent 0..2 k -1
13
Unsigned Addition Let's add 6+3: (6) 10 = (0110) 2 (3) 10 =(0011) 2 0110 + 0011 1001 =( 9) 10
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.