Chapter 1: Data Representation Dr Mohamed Menacer Taibah University
Bits are just bits (0,1) conventions define relationship between bits and numbers conventions define relationship between bits and numbers Binary integers (base 2) decimal: 0, …, 2 n -1 decimal: 0, …, 2 n -1 Of course it gets more complicated: bit strings are finite, but bit strings are finite, but for some fractions and real numbers, finitely many bits is not enough, so overflow & approximation errors: e.g., represent 1/3 as binary! negative integers negative integers How do we represent negative integers? which bit patterns will represent which integers? which bit patterns will represent which integers? Numbers n bits
From Essentials of Computer Architecture by Douglas E. Comer. ISBN © 2005 Pearson Education, Inc. All rights reserved.
IBM's 8-bit extension of the 4-bit Binary Coded Decimal encoding of digits 0-9 ( ), for character encoding.
From Essentials of Computer Architecture by Douglas E. Comer. ISBN © 2005 Pearson Education, Inc. All rights reserved.
Floating Point We need a way to represent numbers with fractions, e.g., numbers with fractions, e.g., very small numbers (in absolute value), e.g., very small numbers (in absolute value), e.g., very large numbers (in absolute value), e.g., – * very large numbers (in absolute value), e.g., – * 10 46Representation: scientific: sign, exponent, significand form: scientific: sign, exponent, significand form: (–1) sign * significand * 2 exponent. E.g., – * more bits for significand gives more accuracy more bits for significand gives more accuracy more bits for exponent increases range more bits for exponent increases range binary point
From Essentials of Computer Architecture by Douglas E. Comer. ISBN © 2005 Pearson Education, Inc. All rights reserved.
Scales, Units, and Conventions Term K (kilo-) M (mega-) G (giga-) T (tera-) = = 1,048, = 1,073,741, = 1,099,511,627,776 Normal UsageAs a power of 2 Term Usage m (milli-) (micro-) n (nano-) p (pico-) Units: Bit (b), Byte (B), Nibble, Word (w), Double Word, Long Word Second (s), Hertz (Hz) Powers of 2 are used to describe memory sizes. Note the differences between usages. You should commit the powers of 2 and 10 to memory.