Binary Math Explained

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the decimal equivalent of the binary number 101101?

  • 45 (correct)
  • 61
  • 53
  • 69

What is the result of the binary addition of 1011 + 0110?

  • 10000 (correct)
  • 11001
  • 10001
  • 11000

What decimal value does the octal number 72 represent?

  • 42
  • 66
  • 50
  • 58 (correct)

What is the octal equivalent of the binary number 11010111?

<p>357 (A)</p> Signup and view all the answers

Convert the hexadecimal number 2B to its decimal equivalent.

<p>43 (D)</p> Signup and view all the answers

What is the hexadecimal representation of the decimal number 165?

<p>A5 (C)</p> Signup and view all the answers

Convert the binary number 11110000 to hexadecimal.

<p>F0 (D)</p> Signup and view all the answers

What is the result of 5 - 3 in binary using two's complement?

<p>00000010 (B)</p> Signup and view all the answers

What is the two's complement representation of -25 using 8 bits?

<p>11100111 (D)</p> Signup and view all the answers

To convert a decimal number to BCD, what is the initial step?

<p>Convert each decimal digit to its binary equivalent. (C)</p> Signup and view all the answers

During binary addition, what is the result of 1 + 1?

<p>0 with a carry of 1 (B)</p> Signup and view all the answers

Which of the following ranges defines a single digit in octal number system?

<p>0-7 (C)</p> Signup and view all the answers

What is the main advantage of using hexadecimal numbers in computing?

<p>They directly represent binary numbers in a more compact form. (C)</p> Signup and view all the answers

If a computer uses 8 bits to represent integers, what is the range of signed integers it can represent using two's complement?

<p>-128 to 127 (D)</p> Signup and view all the answers

Why is the two's complement method preferred for representing negative numbers in computers?

<p>Because it simplifies arithmetic operations. (A)</p> Signup and view all the answers

What is the BCD representation for the decimal number 29?

<p>00101001 (B)</p> Signup and view all the answers

In computing, what is a 'nybble'?

<p>A unit of data equal to half a byte. (B)</p> Signup and view all the answers

What is the sum of the binary numbers 11011 and 10101, expressed as a decimal number?

<p>56 (B)</p> Signup and view all the answers

According to the principles of fractional binary numbers, what value is represented by 0.01?

<p>0.25 (B)</p> Signup and view all the answers

Binary numbers are grouped into threes, which of the following number systems does this refer to?

<p>Octal (C)</p> Signup and view all the answers

Convert $55_{10}$ to octal.

<p>$67_8$ (B)</p> Signup and view all the answers

Assuming you have the binary 1011, pad the number on the left with zeroes to produce an octal number.

<p><code>13_8</code> (B)</p> Signup and view all the answers

Which one of the following was the first microprocessor?

<p>The Intel 4004 (A)</p> Signup and view all the answers

According to the principles of octal digits, can the digit '9' be used?

<p>No, it's not a valid digit in octal (B)</p> Signup and view all the answers

Which of the following are valid hexadecimal characters?

<p>F (C)</p> Signup and view all the answers

Convert 256_{10} to hexadecimal.

<p><code>100_{16}</code> (B)</p> Signup and view all the answers

What must you do to binary numbers before converting them into hexadecimal (base-16)?

<p>Pad the binary number with zeroes to a multiple of <em>four</em> (C)</p> Signup and view all the answers

What is the decimal equivalent of the hexadecimal number 3E8?

<p>1000 (B)</p> Signup and view all the answers

Convert the hexadecimal number A2F to octal.

<p><code>5124_8</code> (A)</p> Signup and view all the answers

To which base would dividing and aggregating the remainders be relevant to?

<p>Converting <em>to</em> an Octal Number (B)</p> Signup and view all the answers

Referring to the math of positive and negative binary numbers, which is a reason to implement the Two's Complement?

<p>Arithmetic circuits are simplified (C)</p> Signup and view all the answers

To represent a number using BCD (Binary Coded Decimal), how should we handle the number 123?

<p>Express <code>1</code>, <code>2</code>, and <code>3</code> in base-2 (B)</p> Signup and view all the answers

Convert the BCD number 1001 0000 0011 to its decimal equivalent.

<p>903 (A)</p> Signup and view all the answers

Given that a human must interact with numbers read on a screen, which of the following representations is often better than straight binary?

<p>Binary Coded Decimal (B)</p> Signup and view all the answers

Which is better for hardware to implement on a computer?

<p>Hexadecimal (C)</p> Signup and view all the answers

Convert 234_(10) to BCD.

<p><code>0010 0011 0100</code> (C)</p> Signup and view all the answers

Which of the following requires more bits to represent a Base-10 (decimal) value?

<p>Binary (Base-2) (B)</p> Signup and view all the answers

A computer displays aircraft squawk codes, and each is labeled as one of the digits 0, 1, 2, 3, 4, 5, 6, 7. What representation are they using?

<p>Octal (C)</p> Signup and view all the answers

Compared to Hex, how would you summarize binary?

<p>Binary is <em>less</em> Space efficient. (C)</p> Signup and view all the answers

What is a Bit Position used for?

<p>Tells you the address, as we start from the right. (B)</p> Signup and view all the answers

Flashcards

Decimal Numbers (Base-10)

Base-10 numbers, like 23,456, can be expressed as a sum of powers of 10 (e.g., 2 x 10,000 + 3 x 1,000...).

What is a Bit?

A digit in binary code; either zero or one.

What are Binary Numbers?

Numbers using a base of two, with only digits 0 and 1.

Bit Positions.

Positions in a binary number which increase from right to left

Signup and view all the flashcards

What are Octal Numbers?

A number system comprised of digits 0 to 7.

Signup and view all the flashcards

Octal Grouping

Representing binary in base-8, with each digit (0-7) corresponding to three bits.

Signup and view all the flashcards

Hexadecimal Numbers

A number system using base-16, includes digits 0-9 and letters A-F.

Signup and view all the flashcards

Hex Grouping

Representing binary with a base-16 system, condensing four bits into one hexadecimal digit.

Signup and view all the flashcards

Binary to Hexadecimal Conversion

Convert binary groups of four to their hex equivalents.

Signup and view all the flashcards

Base Conversions

Term for converting between number systems (binary, decimal, octal, hex).

Signup and view all the flashcards

Decimal to Other Bases

Dividing by the target base and collecting the remainders.

Signup and view all the flashcards

Binary Point

Use dot to separate whole numbers from fractional numbers.

Signup and view all the flashcards

Sign Bit

Use a leading bit to indicate positive (0) or negative (1).

Signup and view all the flashcards

Ones Complement

Invert the bits of a binary numbers (0 to 1, 1 to 0).

Signup and view all the flashcards

Twos Complement

Find the ones complement, then add one.

Signup and view all the flashcards

Binary Addition

A common operation in binary arithmetic.

Signup and view all the flashcards

Binary Overflow

Technique where results exceed available bits.

Signup and view all the flashcards

Binary Multiplication

Treating multiplication as an extended AND function.

Signup and view all the flashcards

Binary Division

Follows elementary/long division.

Signup and view all the flashcards

Binary Coded Decimal (BCD)

Each decimal digit is represented by a 4-bit binary number

Signup and view all the flashcards

Any Base to BCD

Convert to decimal, then make groups for each BCD digit

Signup and view all the flashcards

BCD to Any Base

Convert BCD to decimal, then to target base.

Signup and view all the flashcards

Binary to Octal Conversion

Convert the other numbers, in groups of three, in turn from left to right to equivalent octal digits.

Signup and view all the flashcards

Study Notes

  • Unit 5 is about Binary Math

Decimal Numbers - Base 10

  • Decimal numbers use base 10
  • 23,456 can be written as: 2 X 10,000 + 3 X 1,000 + 4 X 100 + 5 X 10 + 6 X 1
  • 23,456 can be also written as: 2 X 10^4 + 3 X 10^3 + 4 X 10^2 + 5 X 10^1 + 6 X 10^0
  • Decimal fractions are written as: 6.789 = 6 × 10^0 + 7 X 10^-1 + 8 X 10^-2 + 9 X 10^-3
  • A number can be specified as positive or negative by inserting a “+” or “-” at the start

Binary Numbers - Base 2

  • Binary numbers use base 2
  • The digits 0 and 1 are referred to as Binary Digits, or simply bits
  • When count in a binary sequence, using only two digits, count as follows: 0, 01, 10, 11, 100, 101, 110, 111, 1000
  • To remove ambiguity, binary numbers are written with a small “2” as a final subscript: 1011011101000002
  • A binary calculator would only have two number keys “0” and "1"
  • A binary calculator's display would only show a long number displaying O's and

Bit Positions and Decimal Values

  • Bits are counted from right to left, starting with bit 0, then bit 1, 2, 3, and so on.
  • The decimal value of each bit is 2^n, where 'n' is the bit's position
  • For n = 0, 1, 2, 3, 4, 5, 6, 7, the value of 2^n is 1, 2, 4, 8, 16, 32, 64, 128

Unpacking Binary Numbers

  • The method for unpacking binary numbers is identical to what is familiar with in decimal numbers
  • The number 2 is raised to the binary position of each bit, when unpacking binary numbers
  • Since multipliers are only 1 and 0, the “0” terms can be eliminated for simplicity
  • 101101110100000 = 1X2^14 + 0X2^13 + 1X2^12 + 1X2^11 + 0X2^10 + 1X2^9 + 1X2^8 + 1X2^7 + 0X2^6 + 1X2^5 + 0X2^4 + 0X2^3 + 0X2^3 + 0X2^2 + 0X2^1 + 0X2^0
  • 101101110100000 = 1X2^14 + 1X2^12 + 1X2^11 + 1X2^9 + 1X2^8 + 1X2^7 + 1X2^5

Converting a Binary Number to Decimal

  • Recall that 2^1 = 2, 2^2 = 2X2=4, 2^3 = 2X2X2 = 8, 2^0 = 1
  • 101101110100000 = 1X2^14 = 16,384 + 1X2^12 = 4,096 + 1X2^11 = 2,048 + 1X2^9 = 512 + 1X2^8 = 256 + 1X2^7 = 128 + 1X2^5 = 32 = 23,456 base 10

Octal Numbers - Base 8

  • In the early days of computers, programs were loaded by hand, in a binary fashion by bit-switching each line, one bit at a time
  • Setting switches to the correct state, either up or down representing 1 or 0, was how programs were loaded, and 'load' switch pressed
  • Loading programs in this was was very tedious and error prone

Octal Number Representation

  • Octal numbers are made up of digits from 0 to 7
  • Each digit represents three bits of data
  • Three bits of data are grouped into an octal digit
  • A binary number, is Octal Equivalent:
  • 000, is 0
  • 001, is 1
  • 010, is 2
  • 011, is 3
  • 100, is 4
  • 101, is 5
  • 110, is 6
  • 111, is 7

Grouping the Bits - Octal Numbers

  • Bits are grouped into threes, starting from right to left.
  • The leftmost bits can be padded with O's to complete the three bit grouping
  • 10112 rewritten is 001 011
  • It can be converted to: 0012→18, 0112 → 38
  • Thus, 10112 = 138 , which is more compact

Binary → Octal → Binary

  • Begin with a given long binary number e.g. 1011011101000002
  • Group it into threes: 101 101 110 100 000
  • Convert each group of threes into the equivalent octal digit to form the number.
  • 556408 is the equivalent octal

Is Octal "Dead”?

  • Every commercial aircraft has a transponder that's interrogated by ATC to associate a radar return with a specific aircraft
  • Each aircraft is assigned a specific "squawk code” by ATC which is a 4-digit octal number
  • The 8 pushbuttons labelled 0 - 7 are octal

Hexadecimal Numbers - Base-16

  • Some computers used groups of 4 bits to form a different numbering system
  • In the 1960's, IBM in their lines of computers, including models 1800 and 360, used Hexadecimal numbers
  • The first microprocessor (Intel® 4004) was a 4-bit machine, which led to 8-bit, then 16, 32 and now 64-bit machines--each nicely divisible by 4.

What's a Hex Number?

  • The numbers are called hexadecimal, meaning 16
  • The largest digit that can be displayed in a group of four is 11112 = 1510.
  • Since there are 16 different digits, start using letters when the numbers run out, such that 10=A, 11=B, 12=C, 13=D, 14=E and 15=F

Hex Digits

  • Note the digits are 0 to 9, then A to F.
  • Hexadecimals are efficient, as 4 bits are rolled up to 1 digit
  • The relationships between Binary Number, Hexadecimal, and Decimal (Base-10), are as follows:
    • 0000, 0, 0
    • 0001, 1, 1
    • 0010, 2, 2
    • 0011, 3, 3
    • 0100, 4, 4
    • 0101, 5, 5
    • 0110, 6, 6
    • 0111, 7, 7
    • 1000, 8, 8
    • 1001, 9, 9
    • 1010, A, 10
    • 1011, B, 11
    • 1100, C, 12
    • 1101, D, 13
    • 1110, E, 14
    • 1111, F, 15

Converting from Binary → Hex → Binary

  • Start with a large binary number e.g. 1011011101000002
  • It is divided into groups of 4, can pad the left grouping with an extra 0 on the left: resulting in: 0101 1011 1010 00002
  • Each group is converted into its equivalent Hex digit: resulting in: 5BA016

Comparison of Bases

  • Efficiency increases as one transitions from binary, octal and then hexadecimal
  • Hexadecimal only requires one digit to express any decimal number from 0 to 15, while Binary requires four digits
  • Hexadecimal is simply a way to express groups of 4 binary digits
  • Octal is a way to express groups of 3 binary digits
  • There is no simple correlation (on a binary digit basis) between Decimal and either of the other three bases

Base Conversions

  • Numbers can be converted between bases: Hexadecimal, Decimal, Octal, and Binary

Converting from Binary to Other Bases

  • Base 2 is converted easily into various other bases

Binary to Octal

  • The binary number is groped into threes, starting from the right side
  • Each group of three is converted to its octal equivalent

Binary to Hexadecimal

  • Each group is converted into into its hexadecimal equivalent

Converting from Octal to Other Bases

  • Base 8 is easily converted into other bases

Octal to Binary

  • Each group of 3 bits is converted into the equivalent octal digit

Octal to Hexadecimal

  • Three steps are required to convert from octal to hexadecimal
    • Convert the octal number to binary
    • Convert the binary to groups of four
    • Convert the groups of four to hex.

Octal to Decimal

  • The mantissa and exponent method is used to convert octal to decimal
  • Note the base is 8

Converting from Hex to Other Bases

  • Base 16 is easily converted into other bases

Hexadecimal to Binary

  • The hexadecimal digits are converted into groups of four bits
  • The groups are combined into a single binary number

Hexadecimal to Octal

  • Three steps are required in converting from hexadecimal to octal
    • Convert the hexadecimal number to binary
    • Convert the binary to groups of three
    • The groups of three are then converted to octal

Hexadecimal to Decimal

  • This can be done using the exponent method
  • Note the base is 16
  • Recall that A=10, B=11, C=12, D=13, E=14 and F=15.

Conversion from Decimal to Other Bases

  • Converting from decimal to other bases is quite different, as groupings and bits are less useful
  • The general procedure for conversion from decimal to other bases:
    • Conduct an integer division on the number by the base number (16 for hex, 8 for octal, 2 for binary)
    • Set the remainder aside – this is what will be utilized to render the converted number
    • Revert to step#1, this time using the quotient (result) from that step as the new dividend.
    • Stop when the numerator is smaller than the denominator.
    • Accumulate all the remainders from the most recent (MSB) to the first one (LSB) – this will be the newly converted value

Decimal to Binary

  • An integer binary number is divided by 2 repeatedly, and the remainders make up the new binary number.

Decimal to Octal

  • An integer decimal number is divided by a repeatedly, and the remainders make up the new octal number

Decimal to Hexadecimal

  • An integer decimal number is divided by 16 repeatedly, and the remainders make up the new hexadecimal number

Binary Numbers

  • Defined in Mathematical Domain as: Infinite, ranging from -∞ to +∞
  • Defined in Physical Domain as: Defined by hardware (# of bits), for example, an 8-bit device is limited to a range of 00000000 to 111111112, which is 0 to 255 base 10
  • Use of "." symbol is allowed as a Binary Point. This separates digits by powers of 2 (not 10 as in decimal)
  • Use of "+" and "-" is allowed as Positive/Negative values doing math
  • Sign bits are not typically used in binary circuits.
  • Binary point and +/- signs are not defined in hardware---requiring different methods to achieve this functionality

Word, Byte, Nybble and Bit

  • In computing memory is referred to as a "word", "byte", "nybble", and "bit"
  • In the 1970's and 1980's processors were based on groupings of 8
  • Today processors are based on sizes/groupings of 64
  • The Intel 4004 µP was a 4-bit machine
  • The 8008, 8080 and 8085 were 8 bit units
  • The 8086 and 80286 were 16 bit machines
  • The 80386, 80486 and early Pentium™™ were 32 bit machines
  • Current Intel Core processors are 64 bits in length

Numbering of Bit Positions

  • When assigning addresses to bits (i.e. their position), the process begins from the rightmost bit and moves to the left
  • The rightmost bit is called zero, the second one is called one, etc.
  • Bit positions aids in calculating the value of the bit in terms of its decimal equivalent Bit Zero: 2^0 has a value of 1 Bit 4: 2^4 = 16

Fractional Numbers

  • A binary point separates numbers greater than 1 from numbers that are less than one
  • Bits to the left of binary point have exponent weights that are either 0 or > 1
  • Bits to the right of the binary point have exponent weights that are < 1
  • As the number moves toward the left, the value of the bit increases, however when moving toward the right it decreases

Unbundling a Number with Binary Point

  • A binary number 101.111 is expanded to:
    • 1 0 1 . 1 1 1
    • 1X2 0x2^1 1X2^0 1X2^-1 1X2^-2 1X2^-3
    • The equivalent decimal number is 4 + 0 + 1 + 0.5 + 0.25+ 0.125 = 5.875

Negative Numbers (Using a Sign Bit)

  • A method of numbering that is not standard, instead requires definition
  • It requires the definition a finite number of bits to the number.
  • The leftmost bit is defined as the sign bit
  • A “1” in this place denotes a negative number
  • A “0” denotes a positive number
  • However, this is not how negative numbers are normally treated.

Negative Numbers - Ones Complement

  • One method of showing a negative number is known as the one's complement
  • One's complements involves taking the binary number and complementing each bit, that is, change the zeros to ones and the ones to zeros
  • The Ones Complement of 00101001 is 11010110

Negative Numbers - Twos Complement

  • Twos Complement is a more standard approach
  • To determine Twos Complement:
      1. Find the Ones Complement of the number
      1. Add “1” to the Ones Complement to get the Twos Complement

Potential Confusion

  • How to identify if an 8-bit binary number is positive or negative?
  • It is in fact difficult to properly show an 8-bit number with a meaningful "sign”, and requires the use 9 bits

Binary Arithmetic - Addition

  • Binary arithmetic, binary addition tables, are much simpler
  • Binary addition of two or three bits can be summarized in a few rules:
    • 0 + 0 = 0
    • 0 + 1 = 1
    • 1 + 0 = 1
    • 1 + 1 = 10
    • 1 + 1 + 1 = 11
  • There are rules for adding two or three bits

Adding Numbers that Require a "Carry”

  • Similar to decimal addition is the instance when the result of the addition produced the values of “10” or “11” In decimal addition, it need to “carry” a "1" when

Refresher - Twos Complement

  • To express an 8-bit negative number using the Twos Complement method, then carry though with the following steps:
  1. One's Complement: flip the bits
  2. Add 1:
  3. Two's Complement: the negative number displayed as an 8-bit number

Proving That the Twos Complement is Valid

  • To affirm that Twos Complement is truly valid the following statement should hold true: If we add 41 +(-41) the outcome/result is expected to be zero, which does hold true, meaning the mathematical conclusion valid

Example 1 - Subtracting Two Numbers

  • Using binary methods lets calculate 9 – 4 = 5
  • Following set the word length at 8 bits to make reading easier
  • Two's complement is calculated to retrieve the binary equivalent of -4 through binary processes

Example 1 (Continued)

  • Following adding calculate 9 to (-4) to discover the answer of the calculation:
  • Discard the leftmost bit--as it is beyond the limits of the 8-bit word
  • The correct result reads, 1012 = 510. This is indeed correct
  • Example 1 is successfully calculated

Example 2 - Subtracting Two Numbers

  • Calculation of 4 - 9 = -5 is to be handled by binary code
  • Set the word length also at 8 bits to ease the process
  • Again, two's complement is calculated to retrieve the binary equivalent -9 through binary processes

Example 2 (Continued)

  • Addition of 4 to (-9) reveals the calculated answer: But, 11111011 doesn't look like -510.
  • To convert the number back to more recognizable form: transform number back to by performing two's complement which negates it
  • Following two's complement the result is 1012 = 510, which confirms the former conclusion
  • The correct answer is 11111011. It is not 00000101

Multiplication of Two Binary Numbers

  • A few concepts are needed to know, since multiplication can be thought of as an AND function:
    • Multiplication 0 X 0 is equal to 0
    • Multiplication of 0 X 1 is equal to 0
    • Multiplication of 1 X 0 is equal to 0
    • Multiplication of 1 X 1 is equal to 1

Example - Multiplication

  • Let's calculate 910 X 1310 = 11710.

Division of Two Numbers

  • Binary division obeys the same general rules that is abided for the long-form division performed in grade school
  • The calculation of: 12 ÷ 2 = 6, is used to illustrate the method

Binary Coded Decimal (BCD)

  • BCD utilized anywhere that human input or output is mandated, as it is customary to function in decimal numbers.
  • Input devices ex: keyboards, thumbwheel switches, are arranged with decimal number inputs
  • Output devices ex: LED or LCD displays which exhibits numbers in a well known set of numbers
  • It's often the numbers are illuminating various forms

Digital Displays Utilizing BCD Numbers

  • The shown example displays digital LED devices
  • Each digit display holds a decoder that turns a binary input into signals that drive the LED displays For instance, to produce the digit "3", a binary value of 0011 is sent to the leftmost display, and for the value "9", a binary value of 1001 is sent to display.
  • With this operation one can see that 367910 ≠ 0011011001111001, which is the BCD representation that requires the use of 16 bits
  • In the case of when 367910 is equal to 1110010111112 it merely requires of use requires 12 bits

BCD Conversion

  • Each decimal digit will need 4 bits
  • Conversion is summarized within the following table:
    • Binary Value B3 MSB B2 B1 B0 LSB - for 0, 0, 0, 0, 0
    • Binary Value B3 MSB B2 B1 B0 LSB - for 1, 0, 0, 0, 1
    • Binary Value B3 MSB B2 B1 B0 LSB - for 2, 0, 0, 1, 0
    • Binary Value B3 MSB B2 B1 B0 LSB - for 3, 0, 0, 1, 1
    • Binary Value B3 MSB B2 B1 B0 LSB - for 4, 0, 1, 0, 0
    • Binary Value B3 MSB B2 B1 B0 LSB - for 5, 0, 1, 0, 1
    • Binary Value B3 MSB B2 B1 B0 LSB - for 6, 0, 1, 1, 0
    • Binary Value B3 MSB B2 B1 B0 LSB - for 7, 0, 1, 1, 1
    • Binary Value B3 MSB B2 B1 B0 LSB - for 8, 1, 0, 0, 0
    • Binary Value B3 MSB B2 B1 B0 LSB - for 9, 1, 0, 0, 1 The source binary number must first needs to be convert to decimal, and then there after each decimal digit has to be turned into binary

Converting any Base Number to BCD

  • The most direct/straight forward method for converting a number into base BCD is: First convert it to decimal Converting each and every digit into BCD through the assistance of reference/Lookup Tables

Example: Hexadecimal to BCD

  • The following calculation is to convert 27F216 into BCD Without the need to go into details: we uncover that it can be translated into BCD for display.

Converting a BCD Number to Another Base

Converting what was previously BCD code into another base requires the following actions:

  • Firstly conversion of the numerical to its corresponding decimal code
  • Secondly to the designated Base Code

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser