[CS61C FA20] Lecture 06.4 - Floating Point: Examples, Discussion — Transcript
Full transcript
- 0:00and welcome back now let's see some
- 0:02examples and actually make you do some
- 0:04work
- 0:04so let's actually think about how to
- 0:06calculate some floating point
- 0:08back and forth from floating point to
- 0:09decimal and back
- 0:11so here we go first quiz pause the video
- 0:15what's the decimal equivalent
- 0:16of one one thousand one and then three
- 0:19ones and that
- 0:21go pause the video
- 0:25and welcome back see i kind of froze
- 0:27there like i was pretending like i was
- 0:29first
- 0:29okay let's do this together all right
- 0:32well first of all i see a one i think
- 0:34it's a negative number but i don't know
- 0:35if the other part
- 0:36always confuses me let's let's go so i
- 0:38first label them
- 0:39sine exponent significant first thing
- 0:41okay
- 0:42here's my equation i pull my equation
- 0:44out minus 1 to the s can be a negative
- 0:46number
- 0:471 plus significance so that's 1.111
- 0:50already times 2 to the exponent minus
- 0:53127.
- 0:54okay so first one is
- 0:58what's the exponent well that's 128 plus
- 1:00the one is 129.
- 1:02129 minus 127. we're gonna see that is
- 1:06minus that's two sorry that's two so one
- 1:08point one one one times two to the two
- 1:10means i move the binary point to the
- 1:13right
- 1:13two spots so that gives me minus one one
- 1:17one
- 1:17point one now you probably hope you can
- 1:20do this one from here this is like fixed
- 1:21point which is minus
- 1:23seven point not bad
- 1:26okay so that was a great explanation of
- 1:28how to do that with simple numbers we
- 1:29don't like to have
- 1:30a lot of energy in the significant it's
- 1:32just too much work but that's the basics
- 1:34of it pretty cool
- 1:35next one how would you represent
- 1:37one-third
- 1:39wait what this is repeating yeah it is a
- 1:41repeating fraction
- 1:42so in base 10 it's a repeating fraction
- 1:440.333
- 1:46so let's actually start well is there
- 1:48any halves nope there's no 0.5s in there
- 1:50is there any quarters yep that's 0.25
- 1:53okay subtract that off what are you left
- 1:54with okay keep doing this
- 1:56and you'll see that it actually works
- 1:57out to be a it's it's a uh
- 2:00it's a quarter not an eighth plus a 16th
- 2:04plus a 64th and so you'll see that it
- 2:07actually
- 2:08is a quarter a 16th a 64th 256. it
- 2:11actually skips one
- 2:12it starts by skipping one at the half
- 2:14and then every other one
- 2:16that's it so now we can do it if we know
- 2:19that we kind of do a couple of them and
- 2:20now we can actually do it so 2 to the
- 2:22minus 2 to the minus 4 to the minus 6 to
- 2:24the minus 8
- 2:25or let's write it here 0.010101 etc etc
- 2:33times 2 to the 0 because i don't need to
- 2:35move that or shift that at all okay
- 2:37so that's pretty cool
- 2:41so now what's that really when i
- 2:42normalize it remember i have to
- 2:43normalize it
- 2:45that becomes 1.01010101 times 2 to the
- 2:48minus 2
- 2:49okay because i had to shift the boundary
- 2:51point to the right so now to the minus
- 2:532. now you say to yourself
- 2:54how do i store both that exponent and
- 2:57the significant in there
- 2:58sine 0 it's positive number exponent is
- 3:02i got a minus 2
- 3:03plus the 127 to get 125. so the bit
- 3:06pattern has to say 125.
- 3:09and actually it's kind of interesting if
- 3:10you look at the bit pattern 125
- 3:12how many off how many here am i missing
- 3:14this looks pretty
- 3:15how am i missing from being all ones
- 3:17well it's really here i'm missing a two
- 3:19so you can kind of figure out quickly
- 3:21minus two that's i know that i'm too off
- 3:23of that which is 125
- 3:25because i'm missing the twos bit okay
- 3:30significand
- 3:32i just i'll say that another way 127 is
- 3:350
- 3:35and all ones minus 2 says
- 3:39minus 2 which is why there's a hole here
- 3:43and that 1 minus 1 is 0 and that's what
- 3:45that hole is just to make sure that it's
- 3:46significant is zero one zero zero one so
- 3:49i'm left with
- 3:50this bit pattern and that is a third
- 3:52kind of a neat bit pattern
- 3:55all right so let's see if we can
- 3:57actually understand the
- 3:59significant a little bit better and
- 4:01remember i i mentioned this a couple of
- 4:02videos but i want to be clear about it
- 4:060.34 if i give you that some decimal
- 4:08back in it
- 4:09you can say you know 0.34 is really like
- 4:11oh sorry 0.340.
- 4:13it's like having 340 over a thousand
- 4:16or it's like 34 over 100. so it's 3400
- 4:19that's no way to say that
- 4:21same way 0.110 let's think about that
- 4:240.110
- 4:25that's like saying 6 over eight i had
- 4:27three bits for the eight
- 4:29six over eight or three
- 4:32over four same thing point one one over
- 4:35a hundred so this is nice black people
- 4:38like this way of thinking about the
- 4:39significant
- 4:40there's another way of doing it which is
- 4:42you just add up the pieces of it we saw
- 4:45add up the place values
- 4:46so if i have 1.6732 it's really like
- 4:49one ones six tenths seven
- 4:52hundredths etc so 1.100
- 4:56is another way of saying well i have 1 1
- 4:591 half and 1 16. so i can either think
- 5:03of this number as
- 5:049 16 or a half plus a 16
- 5:09which is 9 16. so the two ways of
- 5:11thinking about this
- 5:12let's uh please choose the one that's
- 5:14more appropriate for you that kind of
- 5:15makes
- 5:16sense for you as you're thinking about
- 5:17these numbers but that does help to be
- 5:18able to
- 5:19to work with binary points on the
- 5:21fractional side kind of in a fixed point
- 5:22way
- 5:23all right see the next video
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 06.4 - Floating Point: Examples, Discussion by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 973 words across 156 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.