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.
A positive binary digit is odd if _____________ and even if ______________.
odd if: the rightmost digit is 1
even if: the rightmost digit is 0
Adding a number to itself (provided there are enough bits to represent the result) is equivalent to…
…shifting the representation one bit position to the left.
i.e. 59 + 59 is 00111011 + 00111011 = 01110110
T/F: In the same way that leading 0s do not affect the value of a positive number, leading 1s do not affect the value of a negative number.
True
In order to add representations of different lengths, it is first necessary to _______________________. Which is referred to as ______________.
represent them with the same number of bits
i.e. 000001101 + 111011 should be written as 000001101 + 111111011
referred to as: Sign-EXTension (SEXT)
Overflow
a carry out of the leading digit.
i.e. if adding two positive numbers causes overflow, the result will have a leading 1 as the sign bit
if adding two negative numbers causes overflow, the result will have a leading 0 as the sign bit
T/F: Overflow - the sum of a negative number and a positive number never presents a problem
True
Because their sum will be a number which if positive, will have a lower magnitude (less positive) than the original positive number (because a negative number is being added to it), and vice versa.
A logical variable can have one of two values:
0 (false) or 1 (true)
Bit mask
a binary pattern that enables the bits to be separated into 2 parts (the part you care about and the part you want to ignore)
i.e. the bit mask 00000011 ANDed with any 8-bit pattern will be 00000000, 00000001, 00000010, or 00000011
this highlights the 2 right-most bits that are relevant.
Binary logical functions
Requires 2 source operands
AND
OR
XOR (exclusive-OR :D )
Unary logical functions
Operates on only 1 source operand
NOT (complement operation: output is formed by complementing (inverting) the input)
XOR
Exclusive OR
output is 1 if the two source operands are different
0 if the sources are the same
Truth Table 0 XOR 0 : 0 0 XOR 1 : 1 1 XOR 0 : 1 1 XOR 1 : 0
How to determine if 2 patterns are identical:
If the output of the XOR is all 0s
because the XOR function produces a 0 only if the corresponding pair of bits is identical
Bit Vector
complex system made up of “busy” (0) and “available” (1) units
Floating Point Data Type
Allocates some bits to the range of values, and the rest for precision (except for the sign bit).
ASCII
8-bit code for transferring character code between main CPU and the input (i.e. keyboard) and output (i.e. monitor) devices.
American Standard Code for Information Interchange
Hexadecimal Notation
base 16
Useful for dealing with long strings of binary digits without making errors.
Mainly just used as a convenience for humans for fewer copying errors.
Reduces the number of digits by a factor of 4.