YouTube2Text

[CS61C FA20] Lecture 06.3 - Floating Point: Special Numbers — Transcript

by CS 61C Departmental · 4,758 words · 785 segments · language en · Watch on YouTube

Full transcript

  1. 0:00and we're back so now let's play with
  2. 0:03some special numbers we can do floating
  3. 0:04point numbers and that's
  4. 0:05really good we're you know really really
  5. 0:07far into this
  6. 0:08but let's think about where how we could
  7. 0:11use some of the bits in a clever way we
  8. 0:13call them special numbers
  9. 0:15what's really neat
  10. 0:19you now realize that there are numbers
  11. 0:22big really big numbers right 10 to the
  12. 0:2538ish or so
  13. 0:26but what's past that wouldn't it be nice
  14. 0:30if there was a representation for
  15. 0:31infinity
  16. 0:33they said you know we're doing floating
  17. 0:35point we're doing you know computational
  18. 0:36science
  19. 0:37sometimes it's useful to have an
  20. 0:39infinity it says that i didn't just
  21. 0:41overflow but i overflowed and now
  22. 0:42i'm going to store without being an
  23. 0:44error the number infinity as part of
  24. 0:47this
  25. 0:47so why not produce it not an overflow so
  26. 0:50and that's actually really useful you
  27. 0:51know if i infinity plus some
  28. 0:53some other number is still infinity
  29. 0:54right um infinity is bigger than every
  30. 0:56other number there so you can actually
  31. 0:58use infinity
  32. 0:58you can by the way if you've ever used
  33. 1:01if you've ever done
  34. 1:02um an iterative calculation
  35. 1:06of how to do um the max of a number
  36. 1:10here's you know here's a list of numbers
  37. 1:11i'm gonna do the max what's the identity
  38. 1:14of max
  39. 1:15identity of max says it's the value that
  40. 1:18if you maxed
  41. 1:19any number with that it wouldn't change
  42. 1:20what the max was you know what the
  43. 1:22identity of max is negative infinity
  44. 1:25whatever number you have in your space
  45. 1:27if you max it with negative infinity the
  46. 1:30number stays the same
  47. 1:31so if you're using a max and you're
  48. 1:33starting you say well let's let's
  49. 1:34default to the first element of max is
  50. 1:36you know how do you initialize max you
  51. 1:39know temporary you make some things and
  52. 1:40you're
  53. 1:41accumulating you're going through a list
  54. 1:42and you say what do i initialize max to
  55. 1:44you know my max
  56. 1:46the max would initialize it to well you
  57. 1:48can initialize it to the first element
  58. 1:49that's reasonable
  59. 1:50you could also initialize it to minus
  60. 1:53infinity
  61. 1:54and then as you hit the first element
  62. 1:55you say well hey my max is
  63. 1:57the max of my max the old version the
  64. 2:00old number and the first element the
  65. 2:02eighth element i'm looking at
  66. 2:03well this will always be bigger than
  67. 2:06minus infinity bloop
  68. 2:07it works so rather than initialize it to
  69. 2:08the first element initialize it to
  70. 2:10negative infinity which means it helps
  71. 2:11to have negative infinity
  72. 2:13in your representation pretty cool
  73. 2:17so we can store that here's how it's
  74. 2:19going to do we're going to represent
  75. 2:21the most positive exponent and by the
  76. 2:23way here's a cool thing if you look at
  77. 2:24the binary bits
  78. 2:26you're counting up counting up it
  79. 2:27actually counts up in a really beautiful
  80. 2:29way we'll talk about how to interpret
  81. 2:30this
  82. 2:30and then one more from the biggest
  83. 2:33number
  84. 2:34is infinity it's this beautiful idea
  85. 2:38so it's most positive exponent biggest
  86. 2:41exponent
  87. 2:42all ones eight bits of all ones
  88. 2:44significant is all zeros though
  89. 2:46okay because the biggest up to that was
  90. 2:50all ones minus one so it was 254
  91. 2:53and unsigned and so that was the biggest
  92. 2:57eight bits seven bits seven bits of one
  93. 2:59one bits of zero that was the biggest so
  94. 3:01far
  95. 3:01all ones in your significant all one one
  96. 3:05more
  97. 3:05one more let's wrap what drive one more
  98. 3:07mile in the binary odometer
  99. 3:09this goes up this becomes zero that
  100. 3:11becomes all ones
  101. 3:12that's your infinity so it is one past
  102. 3:14it's like literally getting bigger and
  103. 3:16bigger bigger as you're counting your
  104. 3:16binodometer bigger and bigger bigger and
  105. 3:18then
  106. 3:19bloop there is infinity the next one
  107. 3:21over really beautiful
  108. 3:23zero is before so significant is
  109. 3:26all zeros the exponent is all zeros and
  110. 3:29the sign we got two zeros we knew this
  111. 3:30when we got it
  112. 3:31you already knew when i said sign
  113. 3:33magnitude you said two zeros immediately
  114. 3:35you knew that
  115. 3:37so here's what we got here's what we
  116. 3:38have if we look at this beautiful table
  117. 3:40so what we defined so far is we have all
  118. 3:42zeros is zero this is let's assume just
  119. 3:43looking at
  120. 3:44you know you're ignoring the sign
  121. 3:46obviously so far just looking at the
  122. 3:47exponent and this significant
  123. 3:50we've got if we're going to reserve 255
  124. 3:54and none and so for 255 and 0
  125. 3:57that's going to be my infinity my normal
  126. 4:00number is going to be
  127. 4:011 to 254 and anything okay that's the
  128. 4:04normal floating point i've seen before
  129. 4:06but we haven't told you if we're going
  130. 4:07to reserve 0 and 255
  131. 4:10when this is non-zero well
  132. 4:13that's really interesting let's actually
  133. 4:16play with this so far
  134. 4:17professor kahan said waste not want not
  135. 4:21don't throw bits away if you're saying
  136. 4:22ain't no free lunch
  137. 4:24and we're having trouble you know
  138. 4:25dealing with all the
  139. 4:27making use of all the bits and having to
  140. 4:28give some to get some well i got these
  141. 4:30free bits around if you just hand me
  142. 4:31free bits
  143. 4:32i want to get some i want something out
  144. 4:34of that so what should we use those free
  145. 4:36bits for those free bit patterns
  146. 4:38here's the really clever idea you ever
  147. 4:41have a square root of minus four
  148. 4:43if you don't have complex built into
  149. 4:44your system or zero over zero
  150. 4:48is there error normally errors wouldn't
  151. 4:50it be neat if you had a representation
  152. 4:52for
  153. 4:53not a number it isn't a number it's kind
  154. 4:55of some kind of error
  155. 4:56so we're going to reserve here's the
  156. 4:57cool thing the biggest exponent
  157. 5:01non-zero significant for nands
  158. 5:04that's awesome now why is that useful
  159. 5:07because
  160. 5:07here's the cool thing they contaminate
  161. 5:11as you're working with something deep
  162. 5:13deep down in the bowels of your code
  163. 5:15you create a nan well the anything well
  164. 5:18this how about this number was the
  165. 5:20result of
  166. 5:202 plus that and then whatever that is
  167. 5:22it's ten times that
  168. 5:24and it's six divided by that every time
  169. 5:26that nan
  170. 5:27has another operation with any other
  171. 5:29number it stays a nan nan's like a black
  172. 5:31hole
  173. 5:31zhu you can't get a nan out of a nan so
  174. 5:34that means that nan will percolate its
  175. 5:35way
  176. 5:36all the way up and be nan at the top
  177. 5:38level so again
  178. 5:39low low level nan will bubble its way up
  179. 5:41because they contaminate other
  180. 5:42operations
  181. 5:43that's cool so now at the top level you
  182. 5:45see nano up some must have been
  183. 5:46wrong down and then you trace it down
  184. 5:48with your gdp debugger or other debugger
  185. 5:51now you're gonna say well dan that's
  186. 5:54two to the 23
  187. 5:58minus one possible nands
  188. 6:03they had they had such brilliance in
  189. 6:05their design
  190. 6:06they said that's a lot of bits 223 500
  191. 6:09folks is 8 million
  192. 6:10bits ish they said
  193. 6:14well not only could you have a special
  194. 6:16code remember
  195. 6:17you could do anything with bits right so
  196. 6:19you could almost think about those bits
  197. 6:20as if there were some agreement
  198. 6:23the particular hardware could have some
  199. 6:25set of bits say what kind of error it
  200. 6:27was
  201. 6:27well this was a square root of a
  202. 6:29negative number
  203. 6:30this was a zero over zero this was a
  204. 6:33some
  205. 6:34hyperbolic thing whatever errors might
  206. 6:36get caused by whatever mathematical
  207. 6:37operations you want to do
  208. 6:38you'd have those errors and you might
  209. 6:40have a code for that
  210. 6:42you also might have in some of those
  211. 6:44bits
  212. 6:45you could actually have
  213. 6:48the line number where it happened or any
  214. 6:50other debugging information could be the
  215. 6:52so you could make use of those eight
  216. 6:55million possible bit patterns
  217. 6:56to actually encode where things were if
  218. 7:00i
  219. 7:00down deep know that this happened on
  220. 7:01line number 17 why not return a nan
  221. 7:04in which this part of my significant was
  222. 7:07what kind of nan it is
  223. 7:08and this number bit says printf this was
  224. 7:11and you could have some kind of encoding
  225. 7:12for
  226. 7:13what line it was what it was where what
  227. 7:15what program it came from what file it
  228. 7:17came from you could encode anything
  229. 7:19there
  230. 7:20so that's really neat and very clever
  231. 7:22that they used 8 million bits with the
  232. 7:23potential
  233. 7:24that people could use that in a clever
  234. 7:26standardized way that you could bubble
  235. 7:27up in a debugging way what the nan
  236. 7:29what caused an end and maybe even how to
  237. 7:30resolve it here's some bits for how to
  238. 7:32fix it
  239. 7:33that's pretty cool so that's the idea
  240. 7:35with nands
  241. 7:38you remember there also were these bits
  242. 7:40where the exponent was zero
  243. 7:42but the significant was non-zero and
  244. 7:44here is the problem
  245. 7:46okay there's a gap
  246. 7:49there's a gap around zero by the way
  247. 7:53whatever encoding you ever want if
  248. 7:55here's a zero
  249. 7:57then you have a next number the next
  250. 7:59number should be kind of like
  251. 8:00equal steps it should be like a you know
  252. 8:02like a
  253. 8:03a ruler where the the distance between
  254. 8:06zero and the first number
  255. 8:07and the first or the second number are
  256. 8:08the same it should be like that that's
  257. 8:10not what happens with floating point the
  258. 8:11one i taught you so far
  259. 8:13all you know about floating points so
  260. 8:14far shows you this
  261. 8:16what's the smallest representative
  262. 8:18positive number okay
  263. 8:20well it's this one point
  264. 8:24all zeros right one point all zeros okay
  265. 8:27smallest number
  266. 8:28times two to them what's what's the
  267. 8:30number the exponent was gonna be here's
  268. 8:32my field okay let's do this together
  269. 8:35exponent is gonna be one remember that's
  270. 8:37the smallest one we allowed for
  271. 8:39so that 1 minus 127 is 2 to the minus
  272. 8:42126.
  273. 8:43that's my thing okay so this is 1 times
  274. 8:462 minus 126 okay so that's a that's a
  275. 8:48pretty small number we're pretty happy
  276. 8:49with that
  277. 8:51what's the second smallest number it
  278. 8:53should be double that right i talked
  279. 8:54about before right you want a ruler
  280. 8:56where
  281. 8:56blink 0 smallest number next smallest
  282. 8:59number right equal spaces
  283. 9:00so the next one should be 2 times 2 to
  284. 9:03the minus 1 26 or you'd want to have
  285. 9:052 to minus 1 25 is the next biggest one
  286. 9:07right that's what you want okay doubled
  287. 9:08minus 126 is 2 to the minus 125. that
  288. 9:11should be the next biggest number if
  289. 9:12that like that then we're fine or equal
  290. 9:13spacing
  291. 9:16nope here's how this works the next
  292. 9:19smallest number is the one
  293. 9:21least number one insignificant goes
  294. 9:23bloop and turns on
  295. 9:25well that's one plus there's my implicit
  296. 9:27one this is two to the minus one twenty
  297. 9:29three i told you that before
  298. 9:30two to the minus one twenty three well
  299. 9:33times two to the minus one twenty six
  300. 9:35same thing because my exponent didn't
  301. 9:37change
  302. 9:38so this is the next so 0 is the smallest
  303. 9:40number
  304. 9:411 is the next smallest number okay but
  305. 9:43that one down there
  306. 9:44well that's the truth by 23. this is if
  307. 9:47you look at if you
  308. 9:48distribute this across this becomes 2 to
  309. 9:51the minus 126
  310. 9:52which is here remember i wanted the
  311. 9:53second nonstop to be double that so it's
  312. 9:55equal spacing it's not
  313. 9:56the next number is this really small
  314. 9:59number
  315. 10:00next to it and you're kind of counting
  316. 10:02by 2 to the minus one forty nines if you
  317. 10:04think about it you're counting by
  318. 10:05two to the minus twenty three times two
  319. 10:08to the minus one twenty six
  320. 10:10so you're counting by two to the minus
  321. 10:11one forty nines so all of these guys
  322. 10:14all the separations of all the numbers
  323. 10:16are two to the minus
  324. 10:17149 away from each other but the
  325. 10:20smallest number is 2 to the minus 126.
  326. 10:22so there's this massive gap
  327. 10:268 million times gap it's like an 8
  328. 10:28million chasm
  329. 10:29before you start counting by a small
  330. 10:31thing right eight million is to the
  331. 10:32minus twenty
  332. 10:33two to the twenty three is eight million
  333. 10:35things so this gap is roughly
  334. 10:37eight million times bigger than these
  335. 10:39gaps can you see that
  336. 10:41we don't like that that's crazy and
  337. 10:43what's the
  338. 10:44who am i to blame i'm blaming
  339. 10:46normalization
  340. 10:47it's this implicit one that's the issue
  341. 10:50that's the problem
  342. 10:52well we don't like this gap
  343. 10:56what could we do boy i wish we had some
  344. 10:58bits we've stored i wish
  345. 11:00hey joe do you have any bits left around
  346. 11:03i certainly professor cohen you're a bit
  347. 11:05smartphone i certainly do have some bits
  348. 11:07left around
  349. 11:07can i borrow those bits yeah sure take
  350. 11:10some bits what are you gonna use
  351. 11:11what are you gonna do i forgot what are
  352. 11:12you using for i want to
  353. 11:15fill in that gap wouldn't it be good if
  354. 11:17i did the bits so that
  355. 11:19i use all the bits in here
  356. 11:22now it'll all be even oh wouldn't that
  357. 11:25be amazing
  358. 11:26that's exactly what we do these are
  359. 11:28called d norms
  360. 11:30the solution is the normalization was
  361. 11:32bad well how do you
  362. 11:34undo a normalization you denormalize it
  363. 11:37so that's the idea we don't have an
  364. 11:39implicit leading one i have a leading
  365. 11:42zero
  366. 11:43and the implicit exponent is minus 126.
  367. 11:48so now what's my smallest guy my
  368. 11:50smallest guy
  369. 11:52okay is zero all zero here's my here's
  370. 11:54my here's my four lines okay my
  371. 11:56three lines all zeros is zero that's
  372. 11:58that guy
  373. 11:59what's the next one this is still zero
  374. 12:02that's a one okay you're telling me the
  375. 12:05implicit
  376. 12:06exponent is two to the minus one twenty
  377. 12:07six two to the minus 1 26 is implicit
  378. 12:10okay
  379. 12:12times times
  380. 12:160 point significand
  381. 12:20and that's a 1. well this number is 2 to
  382. 12:23the minus
  383. 12:2423. 2 to the minus 23
  384. 12:28times 2 to the minus 26 is 2 to the
  385. 12:30minus 149.
  386. 12:33remember we like the 149 as the gap
  387. 12:34before so
  388. 12:36that's the smallest number what's the
  389. 12:39next smallest number
  390. 12:41it's double that it's zero zero
  391. 12:44and then well okay the smallest number's
  392. 12:46a one it's one
  393. 12:47zero okay and what's that
  394. 12:51that's 2 to the minus 22
  395. 12:54times 2 to the minus 126 and that's 2 to
  396. 12:58the minus 148.
  397. 12:59remember i said i wanted the next number
  398. 13:01to be double that so it's like
  399. 13:020 and then some number and then double
  400. 13:05that number so that spacing is exactly
  401. 13:06that
  402. 13:07well folks do you realize that 2 to the
  403. 13:08minus 48 is double 2 to the minus 149
  404. 13:11because essentially i am counting by 2
  405. 13:14to the minus 149s
  406. 13:16so this is all evenly spaced
  407. 13:20i'm counting by the two minus 149 and if
  408. 13:22you remember
  409. 13:23now so i'm counting so watches i'm
  410. 13:25taking a stride zero
  411. 13:27take a stride take a baby step because
  412. 13:29it's very small and i'm taking a two to
  413. 13:30the minus 149 step
  414. 13:32bloop and take that step again bloop
  415. 13:34bloop now i'm trying to minus 148.
  416. 13:36now i'm 3 times 2 minus 4.149 and i keep
  417. 13:39counting it's basically
  418. 13:41this number encoded times to the minus
  419. 13:4420 49.
  420. 13:45so when it was when this one when the
  421. 13:46significant i'm going a little faster
  422. 13:48when the significant was
  423. 13:49i don't know 1 100 what's that number
  424. 13:53well this is 12 so it'd be 12 times 2
  425. 13:55minus 149
  426. 13:56and that's 12 in that's that 0 and then
  427. 13:5912 more is that number
  428. 14:00i'm counting by 2 minus 1 49. amazing
  429. 14:04now what happens when i cross over the
  430. 14:07threshold
  431. 14:08and i cross over into the normalized
  432. 14:09numbers what am i counting by then we
  433. 14:11saw that the last slide
  434. 14:13or a couple slides ago i'm also counting
  435. 14:14by 2 to the minus 1 49.
  436. 14:16so it turns out i count i take even
  437. 14:18steps even steps
  438. 14:20until i cross over into the normalized
  439. 14:21numbers and now it's still 2 to the
  440. 14:23minus 149
  441. 14:24even steps what happens when the
  442. 14:27exponent changes
  443. 14:28get one bigger while that exponent
  444. 14:30changes now i'm counting by double that
  445. 14:31now i'm counting by 2 to the minus 248
  446. 14:33which means my stride
  447. 14:34doubles and i do and i have 8 million
  448. 14:37steps 2 to the
  449. 14:3823 8 million ish steps counting by 2 to
  450. 14:42the minus 148.
  451. 14:44exponent goes up by one now i'm cutting
  452. 14:46by double that
  453. 14:47two to the minus 147. so every time i
  454. 14:50cross over an exponent changes by one
  455. 14:52i double my stride so it's like even set
  456. 14:55of numbers
  457. 14:55imagine a ruler even set of numbers all
  458. 14:58evenly here minus two or minus
  459. 14:59one minus one forty nine now i get to
  460. 15:02the normalized number
  461. 15:03to the minus forty minus because that's
  462. 15:05weird that's beautiful that they're
  463. 15:06actually the same spacing
  464. 15:07across the line the boundary between
  465. 15:09denormalized and normalized numbers now
  466. 15:12i cross over now i'm still here
  467. 15:13now as every time i cross an exponent i
  468. 15:16double my stride
  469. 15:17so i'm kind of doubling the spacing in
  470. 15:19my ruler i go and now it's double size
  471. 15:21until it's the next one then double it
  472. 15:23again and every time my exponent
  473. 15:24increases
  474. 15:25i double the size of my stride and
  475. 15:27that's how i have a lot of really small
  476. 15:29numbers
  477. 15:29and i can get to the big numbers as well
  478. 15:31like if i kept going by the small count
  479. 15:32i would never get to
  480. 15:34a big number because i'd be counting by
  481. 15:3524.49 but every time my exponent changes
  482. 15:38i double my stride i double what that
  483. 15:40significant incrementing by one
  484. 15:43changes the step count so i'm stepping
  485. 15:45by double every time i cross
  486. 15:46to a new exponent pretty cool we're
  487. 15:49really happy about this so we love
  488. 15:51d norms so special number summary we're
  489. 15:53doing great love this stuff
  490. 15:55all zeros is zero zero non-zero is my d
  491. 15:58norm space and now you know those are
  492. 15:59counting by two to the minus 49 and they
  493. 16:01fit in perfectly
  494. 16:02i fit in exactly eight million numbers
  495. 16:04in a space so the spacing of them is
  496. 16:06exactly the same as the spacing of the
  497. 16:07area to the right which is the
  498. 16:08normalized node the smallest normalized
  499. 16:10numbers
  500. 16:10that's awesome my normalized numbers you
  501. 16:13saw exponent goes from 1 to 254
  502. 16:15in the unsigned space and that goes is 8
  503. 16:17million here
  504. 16:18then the next 8 million are double
  505. 16:19spaced and the next 8 million are double
  506. 16:21spaced keep doing that that's that space
  507. 16:23until i get to the biggest one i'm
  508. 16:25starting by a huge a
  509. 16:26huge amount a big giraffe step bloop
  510. 16:30bloop so that's almost so it's 254 in
  511. 16:33the exponent
  512. 16:34all one's insignificant that's my
  513. 16:36biggest floating point number
  514. 16:37one more ready one more is
  515. 16:40infinity isn't that crazy i love that
  516. 16:45and now what's one more past infinity
  517. 16:48nan oh there's a cnn's
  518. 16:51because once my significant gets
  519. 16:53non-zero now i'm in my sea of nans
  520. 16:55and i'm just a big huge sea of nans
  521. 16:57that's it
  522. 16:59that's call that's the basics of the
  523. 17:01special numbers now before i leave i
  524. 17:02want to show you this amazing
  525. 17:04demo this is an amazing demo
  526. 17:07this is a simulation
  527. 17:11of the ieee 754 converter
  528. 17:15and i can look at this and i can set the
  529. 17:18bits
  530. 17:19and watch what happens all the bits are
  531. 17:21zero
  532. 17:22it's zero
  533. 17:25what's the smallest number let's now
  534. 17:27count up in our binary odometer what's
  535. 17:28the next smallest number it's the
  536. 17:30smallest dnorm number
  537. 17:32that one is the smallest d-normed number
  538. 17:36that's it that's two to the minus 140
  539. 17:40nine two to the next the next smallest
  540. 17:44is
  541. 17:45that that's 2 minus 140 8
  542. 17:49or 2 times 2 minus 149
  543. 17:52that's 3 times 3 to the minus 149. this
  544. 17:55is amazing still d norms okay
  545. 17:57until let's do this one let's clear it
  546. 17:59let's clear it
  547. 18:01let's clear it here until
  548. 18:04i get to this number if i go minus one
  549. 18:08bloop that is the biggest d norm
  550. 18:12that's it that's the biggest team to
  551. 18:13look it even says it biggest d norm
  552. 18:15okay and i'm representing 1.1 times 10
  553. 18:19to the minus 38 but that's you know
  554. 18:20that's just some numbers that doesn't
  555. 18:21really connect
  556. 18:22now watch this this is
  557. 18:26exactly 2 to the minus 149 away from the
  558. 18:28next number
  559. 18:29which is that's the smallest normalized
  560. 18:33number that's one point let's look at it
  561. 18:35it's 2 to the minus 126. you can see the
  562. 18:37exponent says 2 to minus 126
  563. 18:39times 1.0 times to the minus one twenty
  564. 18:42six is two to minus one twenty six
  565. 18:44okay so that's pretty cool
  566. 18:47now now we're in normalized space plus
  567. 18:50two to the minus one let's get it right
  568. 18:54forty nine because i'm still counting by
  569. 18:58two that's one forty nine every time
  570. 18:59that's right
  571. 19:00okay that's that was two to the minus
  572. 19:02twenty six plus one two one from two to
  573. 19:03minus one forty nine
  574. 19:05and this is two to minus one twenty six
  575. 19:08minus two to one forty nine because
  576. 19:09that's all these things are counted by 2
  577. 19:10to the minus 149 that's
  578. 19:12that's the spacing that's the inter
  579. 19:14ruler line spacing
  580. 19:15okay so far this one right smallest
  581. 19:19normalized number right there boom okay
  582. 19:21which is 2 minus 126.
  583. 19:23now stay with me this is going to go
  584. 19:27okay counting by this i'm counting by 2
  585. 19:30to the minus 1 49 right now
  586. 19:32once this gets to be the next number
  587. 19:34let's go ahead let's go here
  588. 19:35okay the next number bloop there okay
  589. 19:37and now go back down by one
  590. 19:39that's the biggest i was still counting
  591. 19:41by two is my 49s okay
  592. 19:42and now i go bloop up
  593. 19:46and now i'm counting by two that's my
  594. 19:47one now i'm counting by two minus
  595. 19:49two to the minus one forty eight so this
  596. 19:51number is 2 to the minus 125
  597. 19:53plus 2 to the plus and the next one
  598. 19:55would be plus 2 to the minus 148
  599. 19:59because this is 2 to the minus 23 times
  600. 20:022 to the minus 25
  601. 20:03125 is 2 to the minus 148 i'm counting
  602. 20:05by
  603. 20:06get that okay i keep going up
  604. 20:09let's go back here this keeps going
  605. 20:11bigger double start every time i do this
  606. 20:13until i get to
  607. 20:15zero oh that was zero sorry
  608. 20:18until i didn't i did that wrong until i
  609. 20:21get to
  610. 20:22all of these what what happens when i'm
  611. 20:24counting by ones
  612. 20:25where's my one well that's right here
  613. 20:27here's my float
  614. 20:28watch i just typed this to be a one can
  615. 20:31you already figure out what one should
  616. 20:32be
  617. 20:32what should one be like the number one
  618. 20:37well this should be zero and it's one
  619. 20:39point zero which that means zero
  620. 20:41times something that represents one
  621. 20:46well how can i take this set of bits so
  622. 20:49it represents one that should be zero
  623. 20:51two to the zero is one so
  624. 20:54there's a minus 127 here so that means
  625. 20:57this has to be
  626. 20:581 27. ladies and gentlemen
  627. 21:02127 represented here in bits and what
  628. 21:04number is it
  629. 21:071 because that's 127 minus my thing this
  630. 21:10becomes
  631. 21:111.0 no significant times 2 to the
  632. 21:15that by that unsigned 127 minus my bias
  633. 21:18127 is 2 to the 0.
  634. 21:20i get 1.0 times 2 to the 0. there's my
  635. 21:231.
  636. 21:24now what am i counting what's the next
  637. 21:26number up
  638. 21:27well this is 2 to the 0 this is always 2
  639. 21:30to the minus 23 times that thing i'm
  640. 21:32counting by
  641. 21:33so this the next number bigger than 1 is
  642. 21:361 plus 2 to the minus 23.
  643. 21:42okay that's the next number above one
  644. 21:45how far is one from the next number over
  645. 21:47it's two to the minus 23 away
  646. 21:50stay with me and now all the numbers
  647. 21:53from one to two
  648. 21:54how many numbers are there from one to
  649. 21:55two it's all these possible bit patterns
  650. 21:59eight million bit patterns between one
  651. 22:01and two
  652. 22:03so what's the next number watch this
  653. 22:06what's the next number let's make this
  654. 22:08f's make this
  655. 22:09f eight eight eight eight let's make
  656. 22:11this all fs
  657. 22:14okay there that's the biggest number
  658. 22:16less than two
  659. 22:18how far is it away from two two to the
  660. 22:20minus twenty two to the minus twenty
  661. 22:21three we just said that we're counting
  662. 22:23by the that's the hash marks
  663. 22:24what's the next number
  664. 22:282 and now what am i counting by
  665. 22:322 to the minus 23 times 2 to the 1 or
  666. 22:352 to the minus 22 so now the next number
  667. 22:39from two
  668. 22:39now what happens i have eight million
  669. 22:41what between two
  670. 22:43and four it's always between
  671. 22:46powers of two so between one and two
  672. 22:49eight million numbers eight million
  673. 22:51stories
  674. 22:53eight million between two and four
  675. 22:56interesting
  676. 22:57eight million between four and eight
  677. 23:02counting up by two to minus 22 there
  678. 23:05eight million between eight and sixteen
  679. 23:078 million between 16 and 32. you kind of
  680. 23:09get this idea
  681. 23:10it's an equally spaced ruler of 8
  682. 23:12million slots
  683. 23:13between every power of 2 and the next
  684. 23:15power of 2.
  685. 23:17isn't that cool so now you're saying
  686. 23:19well when is it counting by 1
  687. 23:22when is it counting by one can you
  688. 23:23figure it out it's when
  689. 23:25this number times this number times two
  690. 23:28minus 23
  691. 23:29is one so what
  692. 23:33what over here times two minus twenty is
  693. 23:35counting by one
  694. 23:36i don't know twenty three what's twenty
  695. 23:39plus one twenty seven
  696. 23:40let's do it one fifty so what's one
  697. 23:44fifty well this is one twenty eight uh
  698. 23:47one twenty eight we gotta get to one
  699. 23:48fifty what else do i need to do
  700. 23:50how about a 32 that's 160.
  701. 23:54how about that's right thirteen would
  702. 23:56have been what's it okay
  703. 23:58how about 150 144 i need six more
  704. 24:05ladies and gentlemen two go back here
  705. 24:07reset this guy
  706. 24:09two to the 23 times mantissa now i'm in
  707. 24:12eight what's the number here let's do it
  708. 24:14together 8 million
  709. 24:17388 608
  710. 24:21what's the next number from that how
  711. 24:24about 838
  712. 24:268609 ladies and gentlemen 838 8609
  713. 24:33next one eight six ten i'm counting by
  714. 24:36ones now because it's 23 ahead this is
  715. 24:38two to twenty three that's through the
  716. 24:40minus 23
  717. 24:41they cancel now i'm counting by ones
  718. 24:44what happens what's the next thing what
  719. 24:45am i counting by twos let's keep going
  720. 24:48so let's go up let's make this let's go
  721. 24:50back to here
  722. 24:52let's go back to here one more than that
  723. 24:54this is true to 24.
  724. 24:55let's go back down ready for ladies and
  725. 24:57gentlemen that is
  726. 25:00this is two to twenty three oh biggest
  727. 25:03one counting by ones right
  728. 25:04now still counting by ones two or two
  729. 25:06fifteen two
  730. 25:08sixteen okay and that number by the way
  731. 25:11if you didn't notice is 16 meg what's
  732. 25:14the next number above that
  733. 25:17i i claim you're counting by twos i
  734. 25:19claim that this
  735. 25:20single digit is not ones anymore it's
  736. 25:22twos
  737. 25:23which means this is the first number you
  738. 25:26cannot do
  739. 25:27this is the smallest energy you cannot
  740. 25:29do i claim you cannot do sixteen seven
  741. 25:31seven seven
  742. 25:32two one seven because when i click plus
  743. 25:34one it's gonna say two one eight ladies
  744. 25:36and gentlemen
  745. 25:37two one eight
  746. 25:41so can't do 16 777 217
  747. 25:44because i'm counting by twos
  748. 25:47awesome i love this simulator so this
  749. 25:50simulator is amazing
  750. 25:51and i encourage you to play with it oh
  751. 25:53by the way i didn't finish i didn't
  752. 25:54finish
  753. 25:55okay we get really big and we get really
  754. 25:58big
  755. 25:58this is the biggest number let's get the
  756. 26:01biggest number don't don't look at this
  757. 26:02thing don't look don't look here
  758. 26:03get this here don't look don't look
  759. 26:05don't look there
  760. 26:06okay now look that's the biggest
  761. 26:09possible
  762. 26:11floating point number we can store
  763. 26:12there's my 3.4
  764. 26:14times 10 to the 38. that's a really big
  765. 26:17number
  766. 26:19what's one more than that i'm still
  767. 26:21counting with my this is my odometer
  768. 26:23connection let's go by
  769. 26:24my odometer by one ready odometer by one
  770. 26:28infinity one more the next one over
  771. 26:31infinity what's one more past that
  772. 26:35nan is that so cool so anyway
  773. 26:38that's the end of this lecture i hope
  774. 26:40you enjoyed the demo i hope you enjoyed
  775. 26:41playing this please do play with the
  776. 26:42simulator it's really cool for
  777. 26:43understanding how that works
  778. 26:44a lot of big ideas we shared with you
  779. 26:46now and now we'll have a reflection of
  780. 26:48what does that mean for rounding what
  781. 26:51does it mean for example let's do some
  782. 26:52examples let's have some more fun and
  783. 26:54kind of
  784. 26:54understand this bit more all right we'll
  785. 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.