Chapter 2: Bits, Data Types, and Operations Flashcards
Presence of voltage is represented as _____ and absence of voltage as _____.
“1” and “0” (each 0 and 1 is a “bit”)
“bit” is short for ______.
binary digit
If we are limited to 8 bits, we can differentiate at most _______ different values.
256 (i.e. 2^8)
In general, with k bits, we can distinguish at most _____ distinct items.
2^k
unsigned integer
(positive only) a data type with many uses in a computer, such as: counting, and identifying different memory locations in the computer (i.e. like an address).
signed integers
negative and positive
In binary representation, all positive integers have a leading ______.
0
In binary representation, all negative integers have a leading ______.
1
Three possible representations of signed integers:
signed magnitude, 1’s complement, 2’s complement (used on almost every computer manufactured today)
In 2’s complement representation, the choice of representation for negative integers is based on ______.
the wish to keep the logic circuits as simple as possible.
i. e. with ALU, the result of adding a negative and positive integer of the magnitude will always be 0.
(i. e. since 00101 is +5, 11011 is chosen for -5).
Basic mechanism to do addition used by almost all computers:
arithmetic and logic unit (ALU); has 2 inputs and 1 output.
T/F: The carry can always be ignored when dealing with 2’s complement arithmetic
True
If we have A and want to find -A, do the following:
1) Find the complement of A by flipping all of the bits
2) then add 1 (00001) to the complement of A
Binary to Decimal conversion (8-bits):
bits are: a7 to a0
1) If a7 is 0 then the integer is positive, and we can evaluate magnitude; if a7 is 1, then negative and need to first find 2’s complement of the positive number with the same magnitude.
2) Magnitude is: a6 · 2^6 + … + a0 · 2^0
simply add the powers of 2 that have a coefficient of 1.
3) if original number was negative, affix minus sign in front
Decimal to Binary conversion (8 bits):
given a decimal integer value N,
1) find the binary representation of the magnitude of N by forming the equation: N = a6 · 2^6 + … + a0 · 2^0.
Repeat the following until the left side of the equation is 0, each iteration will produce the value of one coefficient a:
a) Subtract the rightmost digit from both sides of the equation (1 if N is odd, 0 if N is even)
b) divide both sides of the equation by 2
2) if the original number N is positive, append a leading 0 sign bit
3) if the original number N is negative, append a leading 0 sign bit, then form the negative of this 2’s complement representation.