Review Binary Basic Conversion Binary Decimal
Review Binary Conversion of decimals Decimal
Review Binary Conversion of non-standard decimals ◦Note: Remember to convert the whole number separately NumberWhole Number Part number 0.22x 2 = NumberWhole Number Part number 1.15x 2 = Solution:
Binary 2 NEGATIVE NUMBERS
bits Each 0 or 1 is a bit of information Bit = binary digit A bit is a single piece of information A nibble is 4 bits of information A byte is 8 bits of information A word refers to a string of bits used is a process by a computer. Eg. A computer might work in 8, 16 or 32 bit words.
bits When we talk about representing a number using 5 bits, it means we have five 0’s and 1’s (9) In binary we’ll typically work with 8 bits (65) As they are strings of bits, we might refer to any of these as a ‘word’ ◦A 5-bit word ◦An 8-bit word
bits In representing a number there are bits that are sometimes referred to as: ◦Most Significant bit ◦Least Significant bit Most significant bit ◦Left most bit ◦In the position for the largest value number Least significant bit ◦Right most bit ◦In the position for the lowest value number Most significant bit – value 16 Least significant bit – value 1
What about negative numbers? How might we represent negative numbers using only 0s and 1s? Let’s consider... ◦Unsigned Binary ◦Sign & Magnitude ◦Two’s Complement
Unsigned Binary This is binary in the format we have already dealt with ◦Deals with positive numbers only ◦No extra bits
Sign and Magnitude Sometimes referred to as signed binary Deals with positive and negative numbers Reserves a bit (the most significant bit) as a ‘sign bit’ Sign bit is used to indicate a positive number (0) or a negative number (1) is + 5 (positive) is - 5 (negative)
Sign and Magnitude Using Sign and Magnitude (with 1 sign bit, and 7 bits for the number), convert the following numbers BinaryDecimal
Sign and Magnitude Using Sign and Magnitude, convert the following numbers BinaryDecimal
Two’s Complement Two’s complement is also used to represent positive and negative numbers. It does not use a sign bit, however the most significant bit does act as an indicator for the sign of the number The two’s complement of a number is the negative representation of a number
Two’s Complement ‘Taking a two’s complement’ means getting the negative representation of a number The easiest way to do this: ◦Start with the positive representation of the number ◦Start from the right most bit and work towards the left ◦Any ‘0’ bits remain the same until the first ‘1’ bit ◦Keep the first ‘1’ bit as a 1 ◦Change every other bit to its opposite (1 0 and 0 1)
Two’s Complement – Start with the positive representation of the number – Start from the right most bit and work towards the left – Any ‘0’ bits remain the same until the first ‘1’ bit – Keep the first ‘1’ bit as a 1 – Change every other bit to its opposite (1 0 and 0 1) 6 is
Two’s complement Follow the steps to determine the 8-bit two’s complement representation of -5 and -10 OriginalBinary Representation Two’s ComplementNew Value 5 10
Two’s complement Follow the steps to determine the 8-bity two’s complement representation of -5 and -10 OriginalBinary Representation Two’s ComplementNew Value
Two’s Complement Important Note!!! You only need to ‘take the two’s complement’ if ◦the number is negative, or ◦the number needs to be subtracted Always start with more bits than you require to represent the number. ◦Eg. 4 can be represented using just 3 bits, to complete two’s complete accurately you must work with at least 4 bits or more