Chapter 2 - Bits, data types, and operations. The following will be discussed in this chapter: How do we represent data in a computer? Computer is a binary digital system, what kinds of data do we need to represent? Unsigned integers, unsigned binary arithmetic,.and other contents. | Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two conditions: presence of a voltage – we’ll call this state “1” absence of a voltage – we’ll call this state “0” Could base state on value of voltage, but control and detection circuits more complex. compare turning on a light switch to measuring or regulating voltage We’ll see examples of these circuits in the next chapter. 2- Computer is a binary digital system. Basic unit of information is the binary digit, or bit. Values with more than two states require multiple bits. A collection of two bits has four possible states: 00, 01, 10, 11 A collection of three bits has eight possible states: 000, 001, 010, 011, 100, 101, 110, 111 A collection of n bits has 2n possible states. Binary (base two) system: has two states: 0 and 1 Digital system: finite number of symbols 2- What kinds of data do we need to represent? Numbers – signed, unsigned, integers, floating point, complex, rational, irrational, Text – characters, strings, Images – pixels, colors, shapes, Sound Logical – true, false Instructions Data type: representation and operations within the computer We’ll start with numbers 2- Unsigned Integers Non-positional notation could represent a number (“5”) with a string of ones (“11111”) problems? Weighted positional notation like decimal numbers: “329” “3” is worth 300, because of its position, while “9” is only worth 9 329 102 101 100 101 22 21 20 3x100 + 2x10 + 9x1 = 329 1x4 + 0x2 + 1x1 = 5 most significant least significant 2- Unsigned Integers (cont.) An n-bit unsigned integer represents 2n values: from 0 to 2n-1. 22 21 20 0 0 0 0 0 0 1 1 0 1 0 2 0 1 1 3 1 0 0 4 1 0 1 5 1 1 0 6 1 1 1 7 2- Unsigned Binary Arithmetic Base-2 addition – just like base-10! add from right to left, propagating carry 10010 10010 1111 + 1001 + 1011 + 1 11011 . | Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two conditions: presence of a voltage – we’ll call this state “1” absence of a voltage – we’ll call this state “0” Could base state on value of voltage, but control and detection circuits more complex. compare turning on a light switch to measuring or regulating voltage We’ll see examples of these circuits in the next chapter. 2- Computer is a binary digital system. Basic unit of information is the binary digit, or bit. Values with more than two states require multiple bits. A collection of two bits has four possible states: 00, 01, 10, 11 A collection of three bits has eight possible states: 000, 001, 010, 011, 100, 101, 110, 111 A collection of n bits has 2n possible states. Binary (base two) system: has two states: 0 and 1 Digital system: finite number of symbols 2- What .