DCN 157 - Introduction To IT (Lecture 3)
DCN 157 - Introduction To IT (Lecture 3)
• -108
• +108 = 01101100 • -5
• from the right, copy all digits through the first one: • +5 = 00000101
• -----100 • from right, copy all bits through the first one:
• flip the rest of the bits (01101) • -------1
• 10010 100 = 10010100 • flip rest of the bits (0000010)
• 1111101 1 = 11111101
Real (Fractional) Numbers
•• Extend our powers of two to the right of the decimal point using negative powers of 2
• 101.1 = 22 + 20 + 2-1
• What is 2-1? 1/21
• 2-2 = 1/22 = 1/4, 2-3 = 1/23 = 1/8
• 10110.101 = 16 + 4 + 2 + 1/2 + 1/8 = 22 = 22.625
• How do we represent the decimal point?
• We use a floating point representation, like scientific notation, but in binary where we store 3 integer numbers, a sign bit (1 =
negative, 0 = positive), the mantissa (the number without a decimal point) and the location of the decimal point as an
exponent
• The point is that we not try to store a decimal point, but we record where the decimal point should be
• For example : 110111.01 = .10110111 * 26
• Mantissa = 11011101
• Exponent = 110 (6, the exponent)
• Sign = 0
• We simply store this as 011011011101
Character Representations
• We need to invent a way to represent or store letters of the alphabet (there is
no natural way)
• Need to differentiate between upper and lower case letters – so we need at least 52
representations
• We will want to also represent punctuation marks
• Also digits (phone numbers use numbers but are not stored numerically)
• 3 character codes have been developed
• EBCDIC – used only by IBM mainframes
• (Extended Binary Coded Decimal Interchange Code )
• ASCII – the most common code, 7 bits – 128 different characters (add a 0 to the front
to make it 8 bits or 1 byte per character)
• Unicode – expands ASCII to 16 bits to represent over 65,000 characters
First 32 characters are control characters (not printable)
Example
• To store the word “Hello”
• H = 72 = 01001000
• e = 101 = 01100101
• l = 108 = 01101100
• l = 108 = 01101100
• o = 111 = 01101111
• Hello = 01001000 01100101 01101100 01101100 01101111
• How much storage space is required for the string
• R U 4 Luv?
• 10 bytes (5 letters, 3 spaces, 1 digit, 1 punctuation mark)
• The ‘U’ and ‘u’ are represented using different values
• ‘U’ = 01010101
• ‘u’ = 01110101
• The only difference between an upper and lower case letter is the 3rd bit from the left
• upper case = 0, lower case = 1
Logical Operators: AND, OR, XOR, NOT Gates
AND NOT
Try this
1 C
OR 1
D
Output at C and D
XOR
Binary Operations
• We learn the binary operations using truth tables