YouTube2Text

Representing Numbers and Letters with Binary: Crash Course Computer Science #4 — Transcript

by CrashCourse · 1,983 words · 170 segments · language en · Watch on YouTube

Full transcript

  1. 0:03Hi I’m Carrie Anne, this is Crash Course Computer Science
  2. 0:06and today we’re going to talk about how computers store and represent numerical data.
  3. 0:10Which means we’ve got to talk about Math!
  4. 0:12But don’t worry.
  5. 0:13Every single one of you already knows exactly what you need to know to follow along.
  6. 0:16So, last episode we talked about how transistors can be used to build logic gates, which can
  7. 0:20evaluate boolean statements.
  8. 0:22And in boolean algebra, there are only two, binary values: true and false.
  9. 0:26But if we only have two values, how in the world do we represent information beyond just
  10. 0:29these two values?
  11. 0:30That’s where the Math comes in.
  12. 0:32INTRO
  13. 0:41So, as we mentioned last episode, a single binary value can be used to represent a number.
  14. 0:46Instead of true and false, we can call these two states 1 and 0 which is actually incredibly useful.
  15. 0:52And if we want to represent larger things we just need to add more binary digits.
  16. 0:55This works exactly the same way as the decimal numbers that we’re all familiar with.
  17. 0:59With decimal numbers there are "only" 10 possible values a single digit can be; 0 through 9,
  18. 1:04and to get numbers larger than 9 we just start adding more digits to the front.
  19. 1:07We can do the same with binary.
  20. 1:09For example, let’s take the number two hundred and sixty three.
  21. 1:12What does this number actually represent?
  22. 1:14Well, it means we’ve got 2 one-hundreds, 6 tens, and 3 ones.
  23. 1:18If you add those all together, we’ve got 263.
  24. 1:21Notice how each column has a different multiplier.
  25. 1:24In this case, it’s 100, 10, and 1.
  26. 1:27Each multiplier is ten times larger than the one to the right.
  27. 1:30That's because each column has ten possible digits to work with, 0 through 9, after which
  28. 1:35you have to carry one to the next column.
  29. 1:37For this reason, it’s called base-ten notation, also called decimal since deci means ten.
  30. 1:42AND Binary works exactly the same way, it’s just base-two.
  31. 1:45That’s because there are only two possible digits in binary – 1 and 0.
  32. 1:49This means that each multiplier has to be two times larger than the column to its right.
  33. 1:53Instead of hundreds, tens, and ones, we now have fours, twos and ones.
  34. 1:57Take for example the binary number: 101.
  35. 2:00This means we have 1 four, 0 twos, and 1 one.
  36. 2:04Add those all together and we’ve got the number 5 in base ten.
  37. 2:07But to represent larger numbers, binary needs a lot more digits.
  38. 2:10Take this number in binary 10110111.
  39. 2:12We can convert it to decimal in the same way.
  40. 2:14We have 1 x 128, 0 x 64, 1 x 32, 1 x 16, 0 x 8, 1 x 4, 1 x 2, and 1 x 1.
  41. 2:24Which all adds up to 183.
  42. 2:26Math with binary numbers isn’t hard either.
  43. 2:29Take for example decimal addition of 183 plus 19.
  44. 2:32First we add 3 + 9, that’s 12, so we put 2 as the sum and carry 1 to the ten’s column.
  45. 2:37Now we add 8 plus 1 plus the 1 we carried, thats 10, so the sum is 0 carry 1.
  46. 2:43Finally we add 1 plus the 1 we carried, which equals 2.
  47. 2:46So the total sum is 202.
  48. 2:48Here’s the same sum but in binary.
  49. 2:50Just as before, we start with the ones column.
  50. 2:52Adding 1+1 results in 2, even in binary.
  51. 2:55But, there is no symbol "2" so we use 10 and put 0 as our sum and carry the 1.
  52. 3:00Just like in our decimal example.
  53. 3:021 plus 1, plus the 1 carried, equals 3 or 11 in binary, so we put the sum as 1 and we
  54. 3:08carry 1 again, and so on.
  55. 3:09We end up with 11001010, which is the same as the number 202 in base ten.
  56. 3:14Each of these binary digits, 1 or 0, is called a “bit”.
  57. 3:17So in these last few examples, we were using 8-bit numbers with their lowest value of zero
  58. 3:21and highest value is 255, which requires all 8 bits to be set to 1.
  59. 3:26Thats 256 different values, or 2 to the 8th power.
  60. 3:30You might have heard of 8-bit computers, or 8-bit graphics or audio.
  61. 3:34These were computers that did most of their operations in chunks of 8 bits.
  62. 3:38But 256 different values isn’t a lot to work with, so it meant things like 8-bit games
  63. 3:42were limited to 256 different colors for their graphics.
  64. 3:46And 8-bits is such a common size in computing, it has a special word: a byte.
  65. 3:51A byte is 8 bits.
  66. 3:53If you’ve got 10 bytes, it means you’ve really got 80 bits.
  67. 3:55You’ve heard of kilobytes, megabytes, gigabytes and so on.
  68. 3:58These prefixes denote different scales of data.
  69. 4:01Just like one kilogram is a thousand grams, 1 kilobyte is a thousand bytes…. or really
  70. 4:068000 bits.
  71. 4:07Mega is a million bytes (MB), and giga is a billion bytes (GB).
  72. 4:11Today you might even have a hard drive that has 1 terabyte (TB) of storage.
  73. 4:15That's 8 trillion ones and zeros.
  74. 4:17But hold on!
  75. 4:18That’s not always true.
  76. 4:19In binary, a kilobyte has two to the power of 10 bytes, or 1024.
  77. 4:241000 is also right when talking about kilobytes, but we should acknowledge it isn’t the only
  78. 4:28correct definition.
  79. 4:29You’ve probably also heard the term 32-bit or 64-bit computers – you’re almost certainly
  80. 4:34using one right now.
  81. 4:35What this means is that they operate in chunks of 32 or 64 bits.
  82. 4:39That’s a lot of bits!
  83. 4:40The largest number you can represent with 32 bits is just under 4.3 billion.
  84. 4:45Which is thirty-two 1's in binary.
  85. 4:47This is why our Instagram photos are so smooth and pretty – they are composed of millions
  86. 4:52of colors, because computers today use 32-bit color graphics
  87. 4:56Of course, not everything is a positive number - like my bank account in college.
  88. 5:00So we need a way to represent positive and negative numbers.
  89. 5:03Most computers use the first bit for the sign: 1 for negative, 0 for positive numbers, and
  90. 5:08then use the remaining 31 bits for the number itself.
  91. 5:11That gives us a range of roughly plus or minus two billion.
  92. 5:14While this is a pretty big range of numbers, it’s not enough for many tasks.
  93. 5:17There are 7 billion people on the earth, and the US national debt is almost 20 trillion dollars after all.
  94. 5:23This is why 64-bit numbers are useful.
  95. 5:25The largest value a 64-bit number can represent is around 9.2 quintillion!
  96. 5:30That’s a lot of possible numbers and will hopefully stay above the US national debt for a while!
  97. 5:34Most importantly, as we’ll discuss in a later episode, computers must label locations
  98. 5:38in their memory, known as addresses, in order to store and retrieve values.
  99. 5:43As computer memory has grown to gigabytes and terabytes – that’s trillions of bytes
  100. 5:47– it was necessary to have 64-bit memory addresses as well.
  101. 5:50In addition to negative and positive numbers, computers must deal with numbers that are
  102. 5:53not whole numbers, like 12.7 and 3.14, or maybe even stardate: 43989.1.
  103. 6:00These are called “floating point” numbers, because the decimal point can float around
  104. 6:04in the middle of number.
  105. 6:05Several methods have been developed to represent floating point numbers.
  106. 6:08The most common of which is the IEEE 754 standard.
  107. 6:11And you thought historians were the only people bad at naming things!
  108. 6:14In essence, this standard stores decimal values sort of like scientific notation.
  109. 6:19For example, 625.9 can be written as 0.6259 x 10^3.
  110. 6:25There are two important numbers here: the .6259 is called the significand.
  111. 6:30And 3 is the exponent.
  112. 6:31In a 32-bit floating point number, the first bit is used for the sign of the number -- positive
  113. 6:35or negative.
  114. 6:36The next 8 bits are used to store the exponent and the remaining 23 bits are used to store
  115. 6:41the significand.
  116. 6:42Ok, we’ve talked a lot about numbers, but your name is probably composed of letters,
  117. 6:46so it’s really useful for computers to also have a way to represent text.
  118. 6:49However, rather than have a special form of storage for letters,
  119. 6:53computers simply use numbers to represent letters.
  120. 6:56The most straightforward approach might be to simply number the letters of the alphabet:
  121. 6:59A being 1, B being 2, C 3, and so on.
  122. 7:02In fact, Francis Bacon, the famous English writer, used five-bit sequences to encode
  123. 7:07all 26 letters of the English alphabet to send secret messages back in the 1600s.
  124. 7:11And five bits can store 32 possible values – so that’s enough for the 26 letters,
  125. 7:16but not enough for punctuation, digits, and upper and lower case letters.
  126. 7:20Enter ASCII, the American Standard Code for Information Interchange.
  127. 7:24Invented in 1963, ASCII was a 7-bit code, enough to store 128 different values.
  128. 7:29With this expanded range, it could encode capital letters, lowercase letters, digits
  129. 7:330 through 9, and symbols like the @ sign and punctuation marks.
  130. 7:37For example, a lowercase ‘a’ is represented by the number 97, while a capital ‘A’ is 65.
  131. 7:42A colon is 58 and a closed parenthesis is 41.
  132. 7:45ASCII even had a selection of special command codes, such as a newline character to tell
  133. 7:49the computer where to wrap a line to the next row.
  134. 7:52In older computer systems, the line of text would literally continue off the edge of the
  135. 7:56screen if you didn’t include a new line character!
  136. 7:59Because ASCII was such an early standard, it became widely used, and critically, allowed
  137. 8:02different computers built by different companies to exchange data.
  138. 8:06This ability to universally exchange information is called “interoperability”.
  139. 8:10However, it did have a major limitation: it was really only designed for English.
  140. 8:15Fortunately, there are 8 bits in a byte, not 7, and it soon became popular to use codes
  141. 8:19128 through 255, previously unused, for "national" characters.
  142. 8:25In the US, those extra numbers were largely used to encode additional symbols, like mathematical
  143. 8:30notation, graphical elements, and common accented characters.
  144. 8:33On the other hand, while the Latin characters were used universally, Russian computers used
  145. 8:37the extra codes to encode Cyrillic characters, and Greek computers, Greek letters, and so on.
  146. 8:42And national character codes worked pretty well for most countries.
  147. 8:45The problem was, if you opened an email written in Latvian on a Turkish computer, the result
  148. 8:49was completely incomprehensible.
  149. 8:51And things totally broke with the rise of computing in Asia, as languages like Chinese and Japanese
  150. 8:56have thousands of characters.
  151. 8:58There was no way to encode all those characters in 8-bits!
  152. 9:00In response, each country invented multi-byte encoding schemes, all of which were mutually incompatible.
  153. 9:06The Japanese were so familiar with this encoding problem that they had a special name for it:
  154. 9:11"mojibake", which means "scrambled text".
  155. 9:13And so it was born – Unicode – one format to rule them all.
  156. 9:17Devised in 1992 to finally do away with all of the different international schemes
  157. 9:21it replaced them with one universal encoding scheme.
  158. 9:23The most common version of Unicode uses 16 bits with space for over a million codes -
  159. 9:28enough for every single character from every language ever used –
  160. 9:32more than 120,000 of them in over 100 types of script
  161. 9:36plus space for mathematical symbols and even graphical characters like Emoji.
  162. 9:40And in the same way that ASCII defines a scheme for encoding letters as binary numbers,
  163. 9:43other file formats – like MP3s or GIFs – use
  164. 9:46binary numbers to encode sounds or colors of a pixel in our photos, movies, and music.
  165. 9:50Most importantly, under the hood it all comes down to long sequences of bits.
  166. 9:55Text messages, this YouTube video, every webpage on the internet, and even your computer’s
  167. 10:00operating system, are nothing but long sequences of 1s and 0s.
  168. 10:03So next week, we’ll start talking about how your computer starts manipulating those
  169. 10:07binary sequences, for our first true taste of computation.
  170. 10:10Thanks for watching. See you next week.

About this transcript

This page contains the full transcript of Representing Numbers and Letters with Binary: Crash Course Computer Science #4 by CrashCourse, generated from the public captions YouTube serves with the video. The transcript has 1,983 words across 170 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 choose a caption track available on the video.

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, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.