[CS61C FA20] Lecture 06.3 - Floating Point: Special Numbers — Transcript
Full transcript
- 0:00and we're back so now let's play with
- 0:03some special numbers we can do floating
- 0:04point numbers and that's
- 0:05really good we're you know really really
- 0:07far into this
- 0:08but let's think about where how we could
- 0:11use some of the bits in a clever way we
- 0:13call them special numbers
- 0:15what's really neat
- 0:19you now realize that there are numbers
- 0:22big really big numbers right 10 to the
- 0:2538ish or so
- 0:26but what's past that wouldn't it be nice
- 0:30if there was a representation for
- 0:31infinity
- 0:33they said you know we're doing floating
- 0:35point we're doing you know computational
- 0:36science
- 0:37sometimes it's useful to have an
- 0:39infinity it says that i didn't just
- 0:41overflow but i overflowed and now
- 0:42i'm going to store without being an
- 0:44error the number infinity as part of
- 0:47this
- 0:47so why not produce it not an overflow so
- 0:50and that's actually really useful you
- 0:51know if i infinity plus some
- 0:53some other number is still infinity
- 0:54right um infinity is bigger than every
- 0:56other number there so you can actually
- 0:58use infinity
- 0:58you can by the way if you've ever used
- 1:01if you've ever done
- 1:02um an iterative calculation
- 1:06of how to do um the max of a number
- 1:10here's you know here's a list of numbers
- 1:11i'm gonna do the max what's the identity
- 1:14of max
- 1:15identity of max says it's the value that
- 1:18if you maxed
- 1:19any number with that it wouldn't change
- 1:20what the max was you know what the
- 1:22identity of max is negative infinity
- 1:25whatever number you have in your space
- 1:27if you max it with negative infinity the
- 1:30number stays the same
- 1:31so if you're using a max and you're
- 1:33starting you say well let's let's
- 1:34default to the first element of max is
- 1:36you know how do you initialize max you
- 1:39know temporary you make some things and
- 1:40you're
- 1:41accumulating you're going through a list
- 1:42and you say what do i initialize max to
- 1:44you know my max
- 1:46the max would initialize it to well you
- 1:48can initialize it to the first element
- 1:49that's reasonable
- 1:50you could also initialize it to minus
- 1:53infinity
- 1:54and then as you hit the first element
- 1:55you say well hey my max is
- 1:57the max of my max the old version the
- 2:00old number and the first element the
- 2:02eighth element i'm looking at
- 2:03well this will always be bigger than
- 2:06minus infinity bloop
- 2:07it works so rather than initialize it to
- 2:08the first element initialize it to
- 2:10negative infinity which means it helps
- 2:11to have negative infinity
- 2:13in your representation pretty cool
- 2:17so we can store that here's how it's
- 2:19going to do we're going to represent
- 2:21the most positive exponent and by the
- 2:23way here's a cool thing if you look at
- 2:24the binary bits
- 2:26you're counting up counting up it
- 2:27actually counts up in a really beautiful
- 2:29way we'll talk about how to interpret
- 2:30this
- 2:30and then one more from the biggest
- 2:33number
- 2:34is infinity it's this beautiful idea
- 2:38so it's most positive exponent biggest
- 2:41exponent
- 2:42all ones eight bits of all ones
- 2:44significant is all zeros though
- 2:46okay because the biggest up to that was
- 2:50all ones minus one so it was 254
- 2:53and unsigned and so that was the biggest
- 2:57eight bits seven bits seven bits of one
- 2:59one bits of zero that was the biggest so
- 3:01far
- 3:01all ones in your significant all one one
- 3:05more
- 3:05one more let's wrap what drive one more
- 3:07mile in the binary odometer
- 3:09this goes up this becomes zero that
- 3:11becomes all ones
- 3:12that's your infinity so it is one past
- 3:14it's like literally getting bigger and
- 3:16bigger bigger as you're counting your
- 3:16binodometer bigger and bigger bigger and
- 3:18then
- 3:19bloop there is infinity the next one
- 3:21over really beautiful
- 3:23zero is before so significant is
- 3:26all zeros the exponent is all zeros and
- 3:29the sign we got two zeros we knew this
- 3:30when we got it
- 3:31you already knew when i said sign
- 3:33magnitude you said two zeros immediately
- 3:35you knew that
- 3:37so here's what we got here's what we
- 3:38have if we look at this beautiful table
- 3:40so what we defined so far is we have all
- 3:42zeros is zero this is let's assume just
- 3:43looking at
- 3:44you know you're ignoring the sign
- 3:46obviously so far just looking at the
- 3:47exponent and this significant
- 3:50we've got if we're going to reserve 255
- 3:54and none and so for 255 and 0
- 3:57that's going to be my infinity my normal
- 4:00number is going to be
- 4:011 to 254 and anything okay that's the
- 4:04normal floating point i've seen before
- 4:06but we haven't told you if we're going
- 4:07to reserve 0 and 255
- 4:10when this is non-zero well
- 4:13that's really interesting let's actually
- 4:16play with this so far
- 4:17professor kahan said waste not want not
- 4:21don't throw bits away if you're saying
- 4:22ain't no free lunch
- 4:24and we're having trouble you know
- 4:25dealing with all the
- 4:27making use of all the bits and having to
- 4:28give some to get some well i got these
- 4:30free bits around if you just hand me
- 4:31free bits
- 4:32i want to get some i want something out
- 4:34of that so what should we use those free
- 4:36bits for those free bit patterns
- 4:38here's the really clever idea you ever
- 4:41have a square root of minus four
- 4:43if you don't have complex built into
- 4:44your system or zero over zero
- 4:48is there error normally errors wouldn't
- 4:50it be neat if you had a representation
- 4:52for
- 4:53not a number it isn't a number it's kind
- 4:55of some kind of error
- 4:56so we're going to reserve here's the
- 4:57cool thing the biggest exponent
- 5:01non-zero significant for nands
- 5:04that's awesome now why is that useful
- 5:07because
- 5:07here's the cool thing they contaminate
- 5:11as you're working with something deep
- 5:13deep down in the bowels of your code
- 5:15you create a nan well the anything well
- 5:18this how about this number was the
- 5:20result of
- 5:202 plus that and then whatever that is
- 5:22it's ten times that
- 5:24and it's six divided by that every time
- 5:26that nan
- 5:27has another operation with any other
- 5:29number it stays a nan nan's like a black
- 5:31hole
- 5:31zhu you can't get a nan out of a nan so
- 5:34that means that nan will percolate its
- 5:35way
- 5:36all the way up and be nan at the top
- 5:38level so again
- 5:39low low level nan will bubble its way up
- 5:41because they contaminate other
- 5:42operations
- 5:43that's cool so now at the top level you
- 5:45see nano up some must have been
- 5:46wrong down and then you trace it down
- 5:48with your gdp debugger or other debugger
- 5:51now you're gonna say well dan that's
- 5:54two to the 23
- 5:58minus one possible nands
- 6:03they had they had such brilliance in
- 6:05their design
- 6:06they said that's a lot of bits 223 500
- 6:09folks is 8 million
- 6:10bits ish they said
- 6:14well not only could you have a special
- 6:16code remember
- 6:17you could do anything with bits right so
- 6:19you could almost think about those bits
- 6:20as if there were some agreement
- 6:23the particular hardware could have some
- 6:25set of bits say what kind of error it
- 6:27was
- 6:27well this was a square root of a
- 6:29negative number
- 6:30this was a zero over zero this was a
- 6:33some
- 6:34hyperbolic thing whatever errors might
- 6:36get caused by whatever mathematical
- 6:37operations you want to do
- 6:38you'd have those errors and you might
- 6:40have a code for that
- 6:42you also might have in some of those
- 6:44bits
- 6:45you could actually have
- 6:48the line number where it happened or any
- 6:50other debugging information could be the
- 6:52so you could make use of those eight
- 6:55million possible bit patterns
- 6:56to actually encode where things were if
- 7:00i
- 7:00down deep know that this happened on
- 7:01line number 17 why not return a nan
- 7:04in which this part of my significant was
- 7:07what kind of nan it is
- 7:08and this number bit says printf this was
- 7:11and you could have some kind of encoding
- 7:12for
- 7:13what line it was what it was where what
- 7:15what program it came from what file it
- 7:17came from you could encode anything
- 7:19there
- 7:20so that's really neat and very clever
- 7:22that they used 8 million bits with the
- 7:23potential
- 7:24that people could use that in a clever
- 7:26standardized way that you could bubble
- 7:27up in a debugging way what the nan
- 7:29what caused an end and maybe even how to
- 7:30resolve it here's some bits for how to
- 7:32fix it
- 7:33that's pretty cool so that's the idea
- 7:35with nands
- 7:38you remember there also were these bits
- 7:40where the exponent was zero
- 7:42but the significant was non-zero and
- 7:44here is the problem
- 7:46okay there's a gap
- 7:49there's a gap around zero by the way
- 7:53whatever encoding you ever want if
- 7:55here's a zero
- 7:57then you have a next number the next
- 7:59number should be kind of like
- 8:00equal steps it should be like a you know
- 8:02like a
- 8:03a ruler where the the distance between
- 8:06zero and the first number
- 8:07and the first or the second number are
- 8:08the same it should be like that that's
- 8:10not what happens with floating point the
- 8:11one i taught you so far
- 8:13all you know about floating points so
- 8:14far shows you this
- 8:16what's the smallest representative
- 8:18positive number okay
- 8:20well it's this one point
- 8:24all zeros right one point all zeros okay
- 8:27smallest number
- 8:28times two to them what's what's the
- 8:30number the exponent was gonna be here's
- 8:32my field okay let's do this together
- 8:35exponent is gonna be one remember that's
- 8:37the smallest one we allowed for
- 8:39so that 1 minus 127 is 2 to the minus
- 8:42126.
- 8:43that's my thing okay so this is 1 times
- 8:462 minus 126 okay so that's a that's a
- 8:48pretty small number we're pretty happy
- 8:49with that
- 8:51what's the second smallest number it
- 8:53should be double that right i talked
- 8:54about before right you want a ruler
- 8:56where
- 8:56blink 0 smallest number next smallest
- 8:59number right equal spaces
- 9:00so the next one should be 2 times 2 to
- 9:03the minus 1 26 or you'd want to have
- 9:052 to minus 1 25 is the next biggest one
- 9:07right that's what you want okay doubled
- 9:08minus 126 is 2 to the minus 125. that
- 9:11should be the next biggest number if
- 9:12that like that then we're fine or equal
- 9:13spacing
- 9:16nope here's how this works the next
- 9:19smallest number is the one
- 9:21least number one insignificant goes
- 9:23bloop and turns on
- 9:25well that's one plus there's my implicit
- 9:27one this is two to the minus one twenty
- 9:29three i told you that before
- 9:30two to the minus one twenty three well
- 9:33times two to the minus one twenty six
- 9:35same thing because my exponent didn't
- 9:37change
- 9:38so this is the next so 0 is the smallest
- 9:40number
- 9:411 is the next smallest number okay but
- 9:43that one down there
- 9:44well that's the truth by 23. this is if
- 9:47you look at if you
- 9:48distribute this across this becomes 2 to
- 9:51the minus 126
- 9:52which is here remember i wanted the
- 9:53second nonstop to be double that so it's
- 9:55equal spacing it's not
- 9:56the next number is this really small
- 9:59number
- 10:00next to it and you're kind of counting
- 10:02by 2 to the minus one forty nines if you
- 10:04think about it you're counting by
- 10:05two to the minus twenty three times two
- 10:08to the minus one twenty six
- 10:10so you're counting by two to the minus
- 10:11one forty nines so all of these guys
- 10:14all the separations of all the numbers
- 10:16are two to the minus
- 10:17149 away from each other but the
- 10:20smallest number is 2 to the minus 126.
- 10:22so there's this massive gap
- 10:268 million times gap it's like an 8
- 10:28million chasm
- 10:29before you start counting by a small
- 10:31thing right eight million is to the
- 10:32minus twenty
- 10:33two to the twenty three is eight million
- 10:35things so this gap is roughly
- 10:37eight million times bigger than these
- 10:39gaps can you see that
- 10:41we don't like that that's crazy and
- 10:43what's the
- 10:44who am i to blame i'm blaming
- 10:46normalization
- 10:47it's this implicit one that's the issue
- 10:50that's the problem
- 10:52well we don't like this gap
- 10:56what could we do boy i wish we had some
- 10:58bits we've stored i wish
- 11:00hey joe do you have any bits left around
- 11:03i certainly professor cohen you're a bit
- 11:05smartphone i certainly do have some bits
- 11:07left around
- 11:07can i borrow those bits yeah sure take
- 11:10some bits what are you gonna use
- 11:11what are you gonna do i forgot what are
- 11:12you using for i want to
- 11:15fill in that gap wouldn't it be good if
- 11:17i did the bits so that
- 11:19i use all the bits in here
- 11:22now it'll all be even oh wouldn't that
- 11:25be amazing
- 11:26that's exactly what we do these are
- 11:28called d norms
- 11:30the solution is the normalization was
- 11:32bad well how do you
- 11:34undo a normalization you denormalize it
- 11:37so that's the idea we don't have an
- 11:39implicit leading one i have a leading
- 11:42zero
- 11:43and the implicit exponent is minus 126.
- 11:48so now what's my smallest guy my
- 11:50smallest guy
- 11:52okay is zero all zero here's my here's
- 11:54my here's my four lines okay my
- 11:56three lines all zeros is zero that's
- 11:58that guy
- 11:59what's the next one this is still zero
- 12:02that's a one okay you're telling me the
- 12:05implicit
- 12:06exponent is two to the minus one twenty
- 12:07six two to the minus 1 26 is implicit
- 12:10okay
- 12:12times times
- 12:160 point significand
- 12:20and that's a 1. well this number is 2 to
- 12:23the minus
- 12:2423. 2 to the minus 23
- 12:28times 2 to the minus 26 is 2 to the
- 12:30minus 149.
- 12:33remember we like the 149 as the gap
- 12:34before so
- 12:36that's the smallest number what's the
- 12:39next smallest number
- 12:41it's double that it's zero zero
- 12:44and then well okay the smallest number's
- 12:46a one it's one
- 12:47zero okay and what's that
- 12:51that's 2 to the minus 22
- 12:54times 2 to the minus 126 and that's 2 to
- 12:58the minus 148.
- 12:59remember i said i wanted the next number
- 13:01to be double that so it's like
- 13:020 and then some number and then double
- 13:05that number so that spacing is exactly
- 13:06that
- 13:07well folks do you realize that 2 to the
- 13:08minus 48 is double 2 to the minus 149
- 13:11because essentially i am counting by 2
- 13:14to the minus 149s
- 13:16so this is all evenly spaced
- 13:20i'm counting by the two minus 149 and if
- 13:22you remember
- 13:23now so i'm counting so watches i'm
- 13:25taking a stride zero
- 13:27take a stride take a baby step because
- 13:29it's very small and i'm taking a two to
- 13:30the minus 149 step
- 13:32bloop and take that step again bloop
- 13:34bloop now i'm trying to minus 148.
- 13:36now i'm 3 times 2 minus 4.149 and i keep
- 13:39counting it's basically
- 13:41this number encoded times to the minus
- 13:4420 49.
- 13:45so when it was when this one when the
- 13:46significant i'm going a little faster
- 13:48when the significant was
- 13:49i don't know 1 100 what's that number
- 13:53well this is 12 so it'd be 12 times 2
- 13:55minus 149
- 13:56and that's 12 in that's that 0 and then
- 13:5912 more is that number
- 14:00i'm counting by 2 minus 1 49. amazing
- 14:04now what happens when i cross over the
- 14:07threshold
- 14:08and i cross over into the normalized
- 14:09numbers what am i counting by then we
- 14:11saw that the last slide
- 14:13or a couple slides ago i'm also counting
- 14:14by 2 to the minus 1 49.
- 14:16so it turns out i count i take even
- 14:18steps even steps
- 14:20until i cross over into the normalized
- 14:21numbers and now it's still 2 to the
- 14:23minus 149
- 14:24even steps what happens when the
- 14:27exponent changes
- 14:28get one bigger while that exponent
- 14:30changes now i'm counting by double that
- 14:31now i'm counting by 2 to the minus 248
- 14:33which means my stride
- 14:34doubles and i do and i have 8 million
- 14:37steps 2 to the
- 14:3823 8 million ish steps counting by 2 to
- 14:42the minus 148.
- 14:44exponent goes up by one now i'm cutting
- 14:46by double that
- 14:47two to the minus 147. so every time i
- 14:50cross over an exponent changes by one
- 14:52i double my stride so it's like even set
- 14:55of numbers
- 14:55imagine a ruler even set of numbers all
- 14:58evenly here minus two or minus
- 14:59one minus one forty nine now i get to
- 15:02the normalized number
- 15:03to the minus forty minus because that's
- 15:05weird that's beautiful that they're
- 15:06actually the same spacing
- 15:07across the line the boundary between
- 15:09denormalized and normalized numbers now
- 15:12i cross over now i'm still here
- 15:13now as every time i cross an exponent i
- 15:16double my stride
- 15:17so i'm kind of doubling the spacing in
- 15:19my ruler i go and now it's double size
- 15:21until it's the next one then double it
- 15:23again and every time my exponent
- 15:24increases
- 15:25i double the size of my stride and
- 15:27that's how i have a lot of really small
- 15:29numbers
- 15:29and i can get to the big numbers as well
- 15:31like if i kept going by the small count
- 15:32i would never get to
- 15:34a big number because i'd be counting by
- 15:3524.49 but every time my exponent changes
- 15:38i double my stride i double what that
- 15:40significant incrementing by one
- 15:43changes the step count so i'm stepping
- 15:45by double every time i cross
- 15:46to a new exponent pretty cool we're
- 15:49really happy about this so we love
- 15:51d norms so special number summary we're
- 15:53doing great love this stuff
- 15:55all zeros is zero zero non-zero is my d
- 15:58norm space and now you know those are
- 15:59counting by two to the minus 49 and they
- 16:01fit in perfectly
- 16:02i fit in exactly eight million numbers
- 16:04in a space so the spacing of them is
- 16:06exactly the same as the spacing of the
- 16:07area to the right which is the
- 16:08normalized node the smallest normalized
- 16:10numbers
- 16:10that's awesome my normalized numbers you
- 16:13saw exponent goes from 1 to 254
- 16:15in the unsigned space and that goes is 8
- 16:17million here
- 16:18then the next 8 million are double
- 16:19spaced and the next 8 million are double
- 16:21spaced keep doing that that's that space
- 16:23until i get to the biggest one i'm
- 16:25starting by a huge a
- 16:26huge amount a big giraffe step bloop
- 16:30bloop so that's almost so it's 254 in
- 16:33the exponent
- 16:34all one's insignificant that's my
- 16:36biggest floating point number
- 16:37one more ready one more is
- 16:40infinity isn't that crazy i love that
- 16:45and now what's one more past infinity
- 16:48nan oh there's a cnn's
- 16:51because once my significant gets
- 16:53non-zero now i'm in my sea of nans
- 16:55and i'm just a big huge sea of nans
- 16:57that's it
- 16:59that's call that's the basics of the
- 17:01special numbers now before i leave i
- 17:02want to show you this amazing
- 17:04demo this is an amazing demo
- 17:07this is a simulation
- 17:11of the ieee 754 converter
- 17:15and i can look at this and i can set the
- 17:18bits
- 17:19and watch what happens all the bits are
- 17:21zero
- 17:22it's zero
- 17:25what's the smallest number let's now
- 17:27count up in our binary odometer what's
- 17:28the next smallest number it's the
- 17:30smallest dnorm number
- 17:32that one is the smallest d-normed number
- 17:36that's it that's two to the minus 140
- 17:40nine two to the next the next smallest
- 17:44is
- 17:45that that's 2 minus 140 8
- 17:49or 2 times 2 minus 149
- 17:52that's 3 times 3 to the minus 149. this
- 17:55is amazing still d norms okay
- 17:57until let's do this one let's clear it
- 17:59let's clear it
- 18:01let's clear it here until
- 18:04i get to this number if i go minus one
- 18:08bloop that is the biggest d norm
- 18:12that's it that's the biggest team to
- 18:13look it even says it biggest d norm
- 18:15okay and i'm representing 1.1 times 10
- 18:19to the minus 38 but that's you know
- 18:20that's just some numbers that doesn't
- 18:21really connect
- 18:22now watch this this is
- 18:26exactly 2 to the minus 149 away from the
- 18:28next number
- 18:29which is that's the smallest normalized
- 18:33number that's one point let's look at it
- 18:35it's 2 to the minus 126. you can see the
- 18:37exponent says 2 to minus 126
- 18:39times 1.0 times to the minus one twenty
- 18:42six is two to minus one twenty six
- 18:44okay so that's pretty cool
- 18:47now now we're in normalized space plus
- 18:50two to the minus one let's get it right
- 18:54forty nine because i'm still counting by
- 18:58two that's one forty nine every time
- 18:59that's right
- 19:00okay that's that was two to the minus
- 19:02twenty six plus one two one from two to
- 19:03minus one forty nine
- 19:05and this is two to minus one twenty six
- 19:08minus two to one forty nine because
- 19:09that's all these things are counted by 2
- 19:10to the minus 149 that's
- 19:12that's the spacing that's the inter
- 19:14ruler line spacing
- 19:15okay so far this one right smallest
- 19:19normalized number right there boom okay
- 19:21which is 2 minus 126.
- 19:23now stay with me this is going to go
- 19:27okay counting by this i'm counting by 2
- 19:30to the minus 1 49 right now
- 19:32once this gets to be the next number
- 19:34let's go ahead let's go here
- 19:35okay the next number bloop there okay
- 19:37and now go back down by one
- 19:39that's the biggest i was still counting
- 19:41by two is my 49s okay
- 19:42and now i go bloop up
- 19:46and now i'm counting by two that's my
- 19:47one now i'm counting by two minus
- 19:49two to the minus one forty eight so this
- 19:51number is 2 to the minus 125
- 19:53plus 2 to the plus and the next one
- 19:55would be plus 2 to the minus 148
- 19:59because this is 2 to the minus 23 times
- 20:022 to the minus 25
- 20:03125 is 2 to the minus 148 i'm counting
- 20:05by
- 20:06get that okay i keep going up
- 20:09let's go back here this keeps going
- 20:11bigger double start every time i do this
- 20:13until i get to
- 20:15zero oh that was zero sorry
- 20:18until i didn't i did that wrong until i
- 20:21get to
- 20:22all of these what what happens when i'm
- 20:24counting by ones
- 20:25where's my one well that's right here
- 20:27here's my float
- 20:28watch i just typed this to be a one can
- 20:31you already figure out what one should
- 20:32be
- 20:32what should one be like the number one
- 20:37well this should be zero and it's one
- 20:39point zero which that means zero
- 20:41times something that represents one
- 20:46well how can i take this set of bits so
- 20:49it represents one that should be zero
- 20:51two to the zero is one so
- 20:54there's a minus 127 here so that means
- 20:57this has to be
- 20:581 27. ladies and gentlemen
- 21:02127 represented here in bits and what
- 21:04number is it
- 21:071 because that's 127 minus my thing this
- 21:10becomes
- 21:111.0 no significant times 2 to the
- 21:15that by that unsigned 127 minus my bias
- 21:18127 is 2 to the 0.
- 21:20i get 1.0 times 2 to the 0. there's my
- 21:231.
- 21:24now what am i counting what's the next
- 21:26number up
- 21:27well this is 2 to the 0 this is always 2
- 21:30to the minus 23 times that thing i'm
- 21:32counting by
- 21:33so this the next number bigger than 1 is
- 21:361 plus 2 to the minus 23.
- 21:42okay that's the next number above one
- 21:45how far is one from the next number over
- 21:47it's two to the minus 23 away
- 21:50stay with me and now all the numbers
- 21:53from one to two
- 21:54how many numbers are there from one to
- 21:55two it's all these possible bit patterns
- 21:59eight million bit patterns between one
- 22:01and two
- 22:03so what's the next number watch this
- 22:06what's the next number let's make this
- 22:08f's make this
- 22:09f eight eight eight eight let's make
- 22:11this all fs
- 22:14okay there that's the biggest number
- 22:16less than two
- 22:18how far is it away from two two to the
- 22:20minus twenty two to the minus twenty
- 22:21three we just said that we're counting
- 22:23by the that's the hash marks
- 22:24what's the next number
- 22:282 and now what am i counting by
- 22:322 to the minus 23 times 2 to the 1 or
- 22:352 to the minus 22 so now the next number
- 22:39from two
- 22:39now what happens i have eight million
- 22:41what between two
- 22:43and four it's always between
- 22:46powers of two so between one and two
- 22:49eight million numbers eight million
- 22:51stories
- 22:53eight million between two and four
- 22:56interesting
- 22:57eight million between four and eight
- 23:02counting up by two to minus 22 there
- 23:05eight million between eight and sixteen
- 23:078 million between 16 and 32. you kind of
- 23:09get this idea
- 23:10it's an equally spaced ruler of 8
- 23:12million slots
- 23:13between every power of 2 and the next
- 23:15power of 2.
- 23:17isn't that cool so now you're saying
- 23:19well when is it counting by 1
- 23:22when is it counting by one can you
- 23:23figure it out it's when
- 23:25this number times this number times two
- 23:28minus 23
- 23:29is one so what
- 23:33what over here times two minus twenty is
- 23:35counting by one
- 23:36i don't know twenty three what's twenty
- 23:39plus one twenty seven
- 23:40let's do it one fifty so what's one
- 23:44fifty well this is one twenty eight uh
- 23:47one twenty eight we gotta get to one
- 23:48fifty what else do i need to do
- 23:50how about a 32 that's 160.
- 23:54how about that's right thirteen would
- 23:56have been what's it okay
- 23:58how about 150 144 i need six more
- 24:05ladies and gentlemen two go back here
- 24:07reset this guy
- 24:09two to the 23 times mantissa now i'm in
- 24:12eight what's the number here let's do it
- 24:14together 8 million
- 24:17388 608
- 24:21what's the next number from that how
- 24:24about 838
- 24:268609 ladies and gentlemen 838 8609
- 24:33next one eight six ten i'm counting by
- 24:36ones now because it's 23 ahead this is
- 24:38two to twenty three that's through the
- 24:40minus 23
- 24:41they cancel now i'm counting by ones
- 24:44what happens what's the next thing what
- 24:45am i counting by twos let's keep going
- 24:48so let's go up let's make this let's go
- 24:50back to here
- 24:52let's go back to here one more than that
- 24:54this is true to 24.
- 24:55let's go back down ready for ladies and
- 24:57gentlemen that is
- 25:00this is two to twenty three oh biggest
- 25:03one counting by ones right
- 25:04now still counting by ones two or two
- 25:06fifteen two
- 25:08sixteen okay and that number by the way
- 25:11if you didn't notice is 16 meg what's
- 25:14the next number above that
- 25:17i i claim you're counting by twos i
- 25:19claim that this
- 25:20single digit is not ones anymore it's
- 25:22twos
- 25:23which means this is the first number you
- 25:26cannot do
- 25:27this is the smallest energy you cannot
- 25:29do i claim you cannot do sixteen seven
- 25:31seven seven
- 25:32two one seven because when i click plus
- 25:34one it's gonna say two one eight ladies
- 25:36and gentlemen
- 25:37two one eight
- 25:41so can't do 16 777 217
- 25:44because i'm counting by twos
- 25:47awesome i love this simulator so this
- 25:50simulator is amazing
- 25:51and i encourage you to play with it oh
- 25:53by the way i didn't finish i didn't
- 25:54finish
- 25:55okay we get really big and we get really
- 25:58big
- 25:58this is the biggest number let's get the
- 26:01biggest number don't don't look at this
- 26:02thing don't look don't look here
- 26:03get this here don't look don't look
- 26:05don't look there
- 26:06okay now look that's the biggest
- 26:09possible
- 26:11floating point number we can store
- 26:12there's my 3.4
- 26:14times 10 to the 38. that's a really big
- 26:17number
- 26:19what's one more than that i'm still
- 26:21counting with my this is my odometer
- 26:23connection let's go by
- 26:24my odometer by one ready odometer by one
- 26:28infinity one more the next one over
- 26:31infinity what's one more past that
- 26:35nan is that so cool so anyway
- 26:38that's the end of this lecture i hope
- 26:40you enjoyed the demo i hope you enjoyed
- 26:41playing this please do play with the
- 26:42simulator it's really cool for
- 26:43understanding how that works
- 26:44a lot of big ideas we shared with you
- 26:46now and now we'll have a reflection of
- 26:48what does that mean for rounding what
- 26:51does it mean for example let's do some
- 26:52examples let's have some more fun and
- 26:54kind of
- 26:54understand this bit more all right we'll
- 26:56see the next time
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 06.3 - Floating Point: Special Numbers by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 4,758 words across 785 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.