binary numbers n.
Download
Skip this Video
Download Presentation
Binary Numbers

Loading in 2 Seconds...

play fullscreen
1 / 34

Binary Numbers - PowerPoint PPT Presentation


  • 60 Views
  • Uploaded on

Binary Numbers. Why Binary?. Maximal distinction among values  m inimal corruption from noise Imagine taking the same physical attribute of a circuit, e.g. a voltage lying between 0 and 5 volts, to represent a number The overall range can be divided into any number of regions .

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Binary Numbers' - noreen


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
why binary
Why Binary?
  • Maximal distinction among values  minimal corruption from noise
  • Imagine taking the same physical attribute of a circuit, e.g. a voltage lying between 0 and 5 volts, to represent a number
  • The overall range can be divided into any number of regions
don t sweat the small stuff
Don’t sweat the small stuff
  • For decimal numbers, fluctuations must be less than 0.25 volts
  • For binary numbers, fluctuations must be less than 1.25 volts

5 volts

0 volts

Binary

Decimal

it doesn t matter
It doesn’t matter ….
  • Recall the power supply voltage measurements from lab 1
  • Ideally they should be 5.00 volts and 12.00 volts
  • Typically they were 5.14 volts or 12.22 volts
  • So what, who cares
how to represent big integers
How to represent big integers
  • Use positional weighting, same as with decimal numbers
  • 205 = 2102 + 0101 + 5100
  • 11001101 = 127 + 126 + 025 + 024 + 123 + 122 + 021 + 120 = 128 + 64 + 8 + 4 + 1 = 205
converting 205 to binary
Converting 205 to Binary
  • 205/2 = 102 with a remainder of 1, place the 1 in the least significant digit position
  • Repeat 102/2 = 51, remainder 0
iterate
Iterate
  • 51/2 = 25, remainder 1
  • 25/2 = 12, remainder 1
  • 12/2 = 6, remainder 0
iterate1
Iterate
  • 6/2 = 3, remainder 0
  • 3/2 = 1, remainder 1
  • 1/2 = 0, remainder 1
recap
Recap

127 + 126 + 025 + 024

+ 123 + 122 + 021 + 120

205

adding binary numbers
Adding Binary Numbers
  • Same as decimal; if sum of digits in a given position exceeds the base (10 for decimal, 2 for binary) then there is a carry into the next higher position
uh oh overflow
Uh oh, overflow
  • What if you use a byte (8 bits) to represent an integer
  • A byte may not be enough to represent the sum of two such numbers
bigger numbers
Bigger Numbers
  • You can represent larger numbers by using more words
  • You just have to keep track of the overflows to know how the lower numbers (less significant words) are affecting the larger numbers (more significant words)
negative numbers
Negative numbers
  • Negative x is that number when added to x gives zero
  • Ignoring overflow the two eight-bit numbers above sum to zero
two s complement
Two’s Complement
  • Step 1: exchange 1’s and 0’s
  • Step 2: add 1
riddle
Riddle
  • Is it 214?
  • Or is it – 42?
  • Or is it …?
  • It’s a matter of interpretation
    • How was it declared?
hexadecimal numbers
Hexadecimal Numbers
  • Even moderately sized decimal numbers end up as long strings in binary
  • Hexadecimal numbers (base 16) are often used because the strings are shorter and the conversion to binary is easier
  • There are 16 digits: 0-9 and A-F
decimal binary hex
0  0000  0

1  0001  1

2  0010  2

3  0011  3

4  0100  4

5  0101  5

6  0110  6

7  0111  7

8  1000  8

9  1001  9

10  1010  A

11  1011  B

12  1100  C

13  1101  D

14  1110  E

15  1111  F

Decimal  Binary  Hex
binary to hex
Binary to Hex
  • Break a binary string into groups of four bits (nibbles)
  • Convert each nibble separately
addresses
Addresses
  • With user friendly computers, one rarely encounters binary, but we sometimes see hex, especially with addresses
  • To enable the computer to distinguish various parts, each is assigned an address, a number
    • Distinguish among computers on a network
    • Distinguish keyboard and mouse
    • Distinguish among files
    • Distinguish among statements in a program
    • Distinguish among characters in a string
how many
How many?
  • One bit can have two states and thus distinguish between two things
  • Two bits can be in four states and …
  • Three bits can be in eight states, …
  • N bits can be in 2N states
ip addresses
IP Addresses
  • An IP address is used to identify a network and a host on the Internet
  • It is 32 bits long
  • How many distinct IP addresses are there?
characters
Characters
  • We need to represent characters using numbers
  • ASCII (American Standard Code for Information Interchange) is a common way
  • A string of eight bits (a byte) is used to correspond to a character
    • Thus 28=256 possible characters can be represented
    • Actually ASCII only uses 7 bits, which is 128 characters; the other 128 characters are not “standard”
unicode
Unicode
  • Unicode uses 16 bits, how many characters can be represented?
  • Enough for English, Chinese, Arabic and then some.
ascii
ASCII
  • 0  00110000
  • 1  00110001
  • A  01000001
  • B  01000010
  • a  01100001
  • b  01100010
booleans
Booleans
  • A Boolean variable is something that is true or false
  • Booleans have two states and could be represented by a single bit (1 for true and 0 for false)
  • Booleans appearing in a program will take up a whole word in memory
fractions
Fractions
  • Similar to what we’re used to with decimal numbers
converting decimal to binary ii
Converting decimal to binary II
  • 98.6
    • Integer part
      • 98 / 2 = 49 remainder 0
      • 49 / 2 = 24 remainder 1
      • 24 / 2 = 12 remainder 0
      • 12 / 2 = 6 remainder 0
      • 6 / 2 = 3 remainder 0
      • 3 / 2 = 1 remainder 1
      • 1 / 2 = 0 remainder 1
    • 1100010
converting decimal to binary iii
Converting decimal to binary III
  • 98.6
    • Fractional part
      • 0.6  2 = 1.2
      • 0.2  2 = 0.4
      • 0.4  2 = 0.8
      • 0.8  2 = 1.6
      • 0.6  2 = 1.2
      • 0.2  2 = 0.4
      • REPEATS
    • .100110
converting decimal to binary iv
Converting decimal to binary IV
  • Put together the integral and fractional parts
  • 98.6  1100010.1001100110011001
scientific notation
Scientific notation
  • Used to represent very large and very small numbers
    • Ex. Avogadro’s number
      •  6.0221367  1023 particles
      •  602213670000000000000000
    • Ex. Fundamental charge e
      •  1.60217733  10-19 C
      •  0.000000000000000000160217733 C
floats
Floats
  • SHIFT expression so it is just under 1 and keep track of the number of shifts
  • 1100010.1001100110011001
  • .11000101001100110011001  27
  • Express the number of shifts in binary
  • .11000101001100110011001  200000111
mantissa and exponent
Mantissa and Exponent
  • .11000101001100110011001  200000111
  • Mantissa
  • .11000101001100110011001  200000111
  • Exponent