all right hello everyone my name is James I'm a computer science graduate turned teacher so in this video series I want to show you everything that you need to know for a level computer science so without further Ado let's dive deep into chapter one information representation so in this chapter this is what you're going to learn you are going to learn how computer can use to Binary to represent number text images sound and what are the compression Technique we can apply to each file format to make the file size smaller so let's go into the first subtopic which we'll talk a little bit about number system how the computer use binary to represent number system great so in the not real life we use dinary numbers which is a base 10 system it's called base 10 system because it has 10 unique values and the value that a digit represents is defined by the place value of this digit so for instance I have a number 365 and each digit here has a vaccinated value so 5 represents five but then the digit 6 here it represents the number 60 whereas the digit 3 here represents 300. so this is what the system we use in our daily life and if you dive deeper into the place value you will know that they are using the base number 10 we started from the least significant bit which is 10 to the power of 0 and then we move the one power up to have the next place value 10 to about 1 10 to the power of 2 which is equal to 100 here whereas in computer science the number system that we'll use very often is called the binary system it is a base 2 system and it only has two unique values and at this point you might ask why binary and that's because a computer is made up of all these electrical components that can only represent two states either on and off so specifically transistors and by having these switches computer can represent various type of data that you can imagine one of them is number so imagine all this one and zero here they are switches one represent open switch and zero represent when the switch is turned off so by having this switch arranging away like that you can see that these can be used to represent numbers and each of the value here they are the place value in the binary system they might look like arbitrary number isn't multiplied by two or just added by two if we die deeper you know that it's just like the dinnere system it is just the base number to the power of zero and we start to increase it as we move across the left hand side so we got one to the power one all the way to no matter how many digits you have all right so the next thing is that you need to know is that eight binary bits here they represent one byte so this is the first terminology and if you have four bits the term we use to describe half a byte is called a nibble enable great besides scenery and binary we also learned about hexadecimal and computer science hexadecimal is a base 16 number system it's called base 16 because it has 16 unit values similar like donary it starts from zero all the way to 9 but not like what you expect it's not 10 in the 10 digit but it's start they use character a to f and the valued a digit represent is again defined by the place value of the digits in the number don't worry if you feel confused because in just a while we are going to look into how to do number conversion and similar to Binary and dinnery this is the place value how they got it 16 to power 0 all the way to the number of digits you have in your hexadecimal right y hexadecimal because and by using just binary it's very hard for us as human to decode what this information is actually talking about and then hexadecimal they helps us to simplify binary representation in fact four binary bits can be written in just one hexadecimal characters and these are the equivalents of binary to hexadecimal and then if let's say you want to convert this randomly to hexadecimal you can also use this system and at this point this might sound very arbitrary but later when we learn about conversion it will be much clearer so some of the usages of hexadecimal you it is used to define Arrow codes IP address which is an address used to identify the network Mac address and address used to identify a device and HTML color codes so these numbers here they are hexadecimal great so now converting let's do the conversion part to know how to represent these numbers in binary and also in hexadecimal imagine that this is the binary number you have what does it represent right so the way to do find out the daenery value of a binary is pretty simple all you need to do is to multiply the digit value by the place value so 16 multiplied by 1 you get 16 8 modified zero you got zero so you know that hey I could just add up those that has the value digit one I can add up 16 plus 4 plus 1. so this is what I meant so I multiply the place value by the digit value and then I sum everything up so you will find out that the answer is 21 you can also find it the answer by using 1 plus 4 plus 16. we know we only care about the one that has digit one so that's how simple it is um that's another question feel free to pause the video if you want to test your understanding but as what I just said all we need to do is only to care about the number the digit that has the value one and then we sum up their place value so this is how I do it one plus two plus eight plus 32 plus 64. and by then you will get the delivery value of the binary numbers so what about the other way round so the way to do it is that we want to keep dividing the delivery number given by two and then obtain the remainder so what I meant is for instance when we divide number five by two we got 2.5 so 2 is the quotient value whereas one is our remainder so we are not done yet we have to keep dividing this number until it reaches zero so 2 divided by 2 you get one and then no remainder one divided by two you will get um yeah great sorry for the delay yeah and then one divided by two it got zero remainder of one and by using the remainder column here you read the answer from the bottom to the top which is 101 and that will give you the binary value of the dinary numbers great so another example 39 you can use 39 divided by two you got 19.5 and 19 is the quotient one is the remainder and you just keep dividing the number by two and I really have the answer here to save you time and as you got all the remainder numbers just compile it from the bottom to the top to receive your binary numbers answers so that's all about how to convert generator to Binary and vice versa great another conversion that you need to do is how to convert binary like that and to half the decimal so for instance let's say you have this is your binary and the way you can convert it to half the decimal is to First understand the concept that we have this binary to hexadecimal conversion table so you can see the land they are pretty nice just plus one from the previous one so start from zero all the way to nine so one zero zero nine is actually nine in binary but also nine it has a decimal but then when it comes to 1010 you know that is 10 in dinary but in hexadecimal there's no digit 10. they only have eight so 1010 represents a and hexadecimal so this if this is the binary you have how do you convert it into hexadecimal right so all you need to do is to first split the binary into a chunk of four and then use the chunk of four bits you refer it you refer the hexadecimal table so one one one zero here it it represents the character e so that means this fourth bits represent the character e and then 0 1 1 1 it simply represents the character seven so your answer would be 7e and that's how you derive the hexadecimal it's just that simple at this point you might ask what if I have a binary that has the length that's not about multiple or form I have 10 bits here I can't split them into chunk of four right so the solution to this is that you need to add two leading zero to the remaining bits here which is what I do here zero zero one one so by looking at 0 0 1 1 referring it to the table you'll get the digit hexadecimal tree so your answer for this binary is three seven e it's the same thing when it comes to converting hexadecimal back to Binary look if C3 is your hexadecimal value if you want to convert it to Binary you can just refer to this table you know that c represents one one zero zero so it's one one zero zero here and three represents zero zero one one and that is exactly what we have in our answers all right the only difficult thing you need to know is to convert this table from scratch because it won't be given an exam but you can essentially first convert this number into hexadecimal I mean into dinary and then use the denary value to identify what's the hexadecimal number all right great now the third the fifth conversion that we'll do is to convert hexadecimal like that into dinary it's very similar to how we convert binary to denary we always just multiply the digit value by the place value and we learned just now that the place value of hexadecimal it starts from one which is 16 to the power of zero you move from Power UP 16 to power of 1 16 to the power of 2 16 power 3. and then once you figure out the place value you can just multiply the digit value by the place value do know that for hexadecimal since it has character and you can't multiply a character by a number so you first need to convert the character hero a represent 10 into numbers e represent 15. all right so it should be 14. I make a typo here so then you can just multiply the digit value by the place value to figure out the answer for the value of dinary for this has a decimal all right and the same thing applies when it comes to the converting the energy to a hexadecimal is very similar to converting binary to Binary all you need to do is to keep divide the number instead of by two you divide it by 16. you get the quotient you get the remainder and then you once again divide 198 by 16 you got 12 remainder of 6 and last but not least 12 divided by 16 got zero remainder of 12. and then you need to convert each number that is greater than 9 into that respective character and then you read the remainder from bottom to top your answer is C 6 B which is what we have here c6b and that's how you convert um from one number system to another number system all right let's move on so in mathematic here are a few ways we can represent large number so instead of saying something has 689 000 grams we sometimes use standard form or we use something called the prefix kilo kilo represents a thousand and that makes our life easier so that's the decimal prefix table something we use in our day-to-day life but for computer science we have something called the binary prefix so the only difference is that instead of having one key key B is instead of equal to 1000 is equal to 1024 and the reason computer science scientists use this system is because um when the new digit is added to Binary the value is always multiplied by two so if you have only one bit yeah this is the only value here when you add one more bit you multiply the value by two and when it multiplied to the valuable two by ten times you get the digit 1024 and the computer science is pick this number to be the prefix so that computer can work better with these prefixes all right so just a recap on all the terminology that we have learned regarding the storage all right so when you have four bits it's called one nibble when you have eight bits it's called one byte and you have one KB bit KB byte this is when things get a little complicated you got 1024 bytes in one kiwi bit KB bytes all right instead of just um 1000 and when it comes to maybe buys the formula is simple one maybe buys it just simply represents 1024 one KB byte so that will give you a pretty good formula to know how to convert from one form to another so if you have bet and you want to convert it to byte simply divide by eight and you want to convert buys into QB byte just divide by 1024 and just follow this formula to keep converting up and down I'm going to show you a few questions to really utilize these formulas so the first question said convert 8 million 8.75 million bytes into maybe byte so you know that price is over here and in order to convert it to maybe byte you first need to divide by 1024 to get the value in KB byte first but we're not done yet what we want is maybe byte so you just divide your number here again by 1024 and you should get 8.34 maybe bytes so that's how you convert um one from one prefix to another type of three phase so let's do another question but in reverse order convert 1.34 GB to kilobyte so firstly you know that you are here and you want to convert it to maybe byte in first and you will multiply it by 1024 which you'll get 1300 72 megabytes so just multiply it again and you should get the amount of bytes in KB byte so that's just how simple it is all you need to do is to remember this formula here all right great now that we have learned how to represent positive number in binary we're now we have a new challenge here as computer scientist because while we can represent number like that in binary how do we represent number like that pop the negative number because even if we were to put zero for all the bits it would still be zero it can't be negative 32 right so this is why computer scientists developed this system called two complement so essentially they only make one change and the change is to make the leftmost bit the sign bit which means there's only act as a sign and we just make the place value of the bit here to be negative look so by making the place value here negative now we have the way to come to convert this into binary right so what I would do is just I'll put one at the negative 64 and then put in the one in 32 place value so when you do negative 64 plus 32 you got negative 32. so all you need to remember is that for tooth complement the only difference is that we now have assignment and if this bit is one it means that it's a negative number but if this bit turns out to be um zero it means this is a positive number so let's do another question now if I want to represent negative seven in the four bits um to a complement like that definitely I have to put this as one and in order to make it negative seven I just have to add the 1 to my negative eight So my answer should be one zero zero one right one zero zero one so that's that's simple all right so um if we were to convert it into the other way around a two complement like that you know that first base negative it's very much the same thing as how we convert a binary to denary we just multiply the digit value by the pillage value and that's what you just add up all the stuff that has one as a digit value and you should get the number in dinnery pretty cool right great so another thing give the smallest and largest two complementary can that can be represented using eight bits so if you were to ask this question just know that to make the smallest number let's start with smallest all you need to do is that set this at one and set everything here as zero because anything that you put one here will add up to the value that will now be smallest so the smallest value that a two complement binary number can represent is negative 128. okay what about the largest to make the largest two complement number all you need to do is to set this negative number as zero and then set everything else here as one so that will be our largest two complement numbers all right great um one fact that you need to know is that sometimes if you have two different two complements here it might still you to the same generally result for example one one zero zero and one one zero so if you were to sum them all up you will get the same value negative four for both so that's just a fact that you need to know you might have two different tools complement number but they can have the same generally value great so that's all about positive and negative numbers so now we learn how to use binary to represent number but we need a way to either to carry down arithmetic operations on them so one thing that we need to learn is that how do we add up these binary numbers so just recap this is how we add up generally numbers so three plus nine you got 12. so but you don't have the digit 12 in denary so you put a 2 here and you have a carry and then you move on whoever asks for binary is very similar but there's a different um as compared to Theory some notes that you need to know is that there is a poster obviously you got zero zero plus one and one plus zero you got one sorry I have a typo again but one plus one you actually got instead of two remember in binary you don't have the digit two one plus one you got one zero it's like zero here and then you carry to the other side and you have one plus one plus one it's technically like one zero plus one so you get one one here so in order to let's say I have two binary numbers here and you are you want to sum them all up 111 plus one zero one first you know that one plus one equal to one zero and hence your result here will be zero with a carry of one and followed by one plus one again you got one zero so it should be zero here and then another carry of one another one one plus one plus one you got one one so you got one and then another carry so the summation of the operation here will be one one zero zero the same goes to subtracting so this is how we subtract stuff if you don't have enough digits so let's say three minus nine it can't be minus so you need to borrow one from the other side so you got 13 minus nine you got four but then here become eight eight minus two got six so this thing goes to binary all right say something you need to know zero minus zero is equal to zero and zero minus one equal to one after you borrowed it so let me explain imagine that I'm having one one zero minus zero and one so zero minus one it can't be minus because it's less than that so I borrow one from the other side so I got one one zero instead so one zero minus one it will be one okay so since now this number has been borrowed it's zero again zero can't be minus can be used to minus one so I borrowed it again so I got one zero minus one I got one again all right so it's very similar to how you carried out addition and subtracting in binary the only difference is that now you don't have two as a digit and that can be a bit tricky for some of you great so that's binary aromatic you add and you subtract so when it comes to adding binary numbers there is a possibility that you might face this problem called overflow problem so I'm adding this two bits binary together and after the operation you see that I generated an X drop it and normal binary operation this might not be a problem but then for a computer it could be a different because for computer to store bits like that just imagine that these bits are stored and components there are starting components in a CPU core register which we'll talk about in chapter four but bear in mind that these register they have often have fixed size meaning they can only store a certain number of bits so after the addition imagine that you are storing the result into this register but then the register can only store eight possible bits as a result the bits that you just generated here will become the last bit and this can cause trouble because now this is no longer the summation of the following binary numbers this is why we have problem um called the Overflow problem in which an extravit is generated yet the register cannot handle cannot store all the bits so this is why we will learn in chapter 6 why is it important to detect overflow and the output and error message so another example here is that when I try to add up two two's complement number and then you'll find out that hey this extra bit is generated it looks fine but then since it's in two complements you ended up getting a positive result negative result when you add two positive numbers together which is incredulous which is not what we want but we'll learn more about that in chapter six for now just know that this is a problem called the Overflow problem great the third thing we need to learn is called the binary coded decimal there are a lot of numbers already I understand that but apparently they're in your syllabus so this type of system is a little bit special and I promise you it's very very easy this is the dinnery value for the binary value here and how this works is that instead of converting let's say I have the number 389 instead of using the division method each digit here is represented by binary instead so instead of 3a9 it will be equal to they will first decode 3. which was 0011 in binary eight in binary and then nine when there's a one in binary and then there was niche the number together so that's PCD basically each digit here is represent is converted directly to Binary without any sophisticated tools and there are two types of BCD the first type of obesity is that one BCD per byte meaning I'm representing one digit using one byte of data which is eight bits so that can cause some wastage this is when we have the second method called the pack BCD 2bcd per bike so instead we use only one nibble four bits for one character here great so this is the summary of The two types of data you can see that one form would take more bits than the other form and both datas are the same so this is important um when it comes to usages and calculator so when six zero is displayed under hood of it is basically they are usually using binary coded decimal and the importance of it will will discuss more in chapter 16 when it comes to the floating Point numbers lecture so another Edition say we want to add the following numbers it's a floating point which is decimal and assuming that two byte pack BCD is used meaning I only represent one I only use four bits to represent one digit so this is the BCD 0.87870.28 but then as you add them all up let's say you add the binary here you'll find out that hey you got an invalid number right why are this value invalid right because if we'll go back to the table here you know that in general the maximum number is 9. so technically you should not have binary representation that has more than one zero zero one so if we were to go back here we got an invalid value here the first one is already invalid so you got one one one one which is equivalent to 15 in dignity but you know that there's no digit 15 in a generation system same goes to 1010 you know that is 10 in daenery but there's no 10 and a itinerary system in other words we say hey why can't convert this back into generally properly and this is why we have special operation for BCD operate operation what how the processor works is that once you add up both digits here and you detect that hey there is an arrow what the computer would do it's quite arbitrary but let me explain first you need to add the first 4-bit with the another four bit called zero one one zero and then when you add them all up this is what you have and potentially with a carry and then you're going to move this carry to the other side you're gonna add the other chunk of 4 bits by 0 1 1 0 again and also add up the carry that you have just now so once you do that this is the result one yeah great so um and then once you have another carry you add it up to the next byte here so this is when everything is sort of achieved so let me repeat step one we added one one zero to the rightmost bit we add another one zero one zero again plus the carry so now you have another carry so you move to the other side so you got zero zero plus one which is zero zero one and then if you were to convert this back into this um the daenery you can find that hey now you got the correct answer the the one is one and the other one is one zero one zero one is five so basically that's just the steps that you need to take when it comes to BCD operations right great now enough about my numbers let's move on to test how the computer represent text like a b c d e to Z and how do they represent something like Emoji by just using binary codes So today we're going to just dwarf into the following two system we namely ASCII and Oso Unicode one is better than the other great ASCII is standard for American Standard curve for information X in the changes I have to remember this so how it works is that you can represent each character by using a byte of binary codes so think of it like um decoding stuff each character here has a specific code so for instance if I want to represent back in binary all I need to do is to refer to this ASCII table and we know that b stands for zero one zero zero zero zero zero one zero and then and so on and so forth so this is essentially how um to represent ASCII code I mean sorry to represent characters in binary so when you snitch them all up that will give you the binary for um this character here so some facts on ASCII is that they could only have a limited number of codes representing non-printing or control character all right so so some of the ASCII code here even though they have many bits some of this code has to be used for non-character and majority of codes represent English text elements like uppercase and lowercase punctuations digit and arithmetic symbols and you will know that um codes for number and letters follow a sequential pattern so you can see the ASCII code for d and e they only separate it by just one technically just I need to add one to the RC code of D to get um the ASCII code for E all right and the other fact that you can know is that oh uppercase and lowercase characters only vary in the value of bit number six so if we could compare the ASCII for D look at this the only difference 0 0 1 0 1 0 0 0 is only at the bit number six that's the only difference so that's just a fun fact Sasuke only uses seven bits and then later they abstracted the ASCII code to use eight bits instead that's what we call the extended ASCII but if you look into it it bits are still not very enough considering the many languages that computer needs to represent like French Chinese um Emoji so this is why Unicode is developed so they use a lot more than just 8 Bits And for Unicode we you're going to learn about the following four structure one bytecode two byte code three by code four by code basically they are variable in terms of their length meaning um instead of using just 8-bit for every character some characters might use more bits than the other so let me explain it in a visual term so this is the format for one bytecode and by using this format zero is always the starting position from one bytecode and then you have seven available bits so there are seven two to the power seven combinations of characters that you can represent using one by code and that's what two byte codes you will have starting character the first byte is going to start with four one zero second byte start with one zero and with this you have 11 possible combinations you got 2 to the power of 11 and 3 bytes so here's the format one one zero followed by one zero one zero and one one zero blah blah blah so and these are the number of computation combinations and initially when I was learning this I found out why why do we need so much um code default code why don't we just make everything as a question mark so that we can have more combinations so this might be what you're thinking now but as we look into the this example you should know why we need these import this starter code and because the starter code allows the computer to identify when is the beginning and when is the end of you know of each byte so imagine that I have a bunch of binary code here and then we got the problem how does the computer know which Unicode structure is this are you using one by two by three bytes or four bytes so now because we know first a specific structure of the bytecode here we are able to identify that so let me explain it reads the first few bits to identify whether it's a one slash two three four byte Unicode so let's say I'm reading this it reads the first four bits 1110 and identify that this is the stunning bits of a tribal Unicode so look only the three by unique code has a starting value of one one one zero great so this is when it knows it's a three byte code it will then read know that the following three bytes are in continuation and find the corresponding character which is first byte second byte third byte orders belong to one specific character so in other words no this is the beginning and this is the end and now once it reaches the end it'll read another starter code 110 and the computer will know that hey one one zero or the starting code for a two byte Unicode so if we lookable back here only one ones two byte Unicode has one one zero as the starting point so by using this it detects that hey then you know that the following two bytes bought number one by number two are in continuation then I was this is a very clever system for the computer to identify what structure are you actually using all right so the initial bits and the buy sequence for a UTF encoded character they just serve as a marker to indicate how many bytes are used to represent that character so we have these following four types so let me drink some water all right now we have learned how to represent numbers I hope they represent text so let's look into how to represent images so there are two ways that computer can represent image the first way is called the vector graphic so vector graphics are images defined by mathematical equation allowing for scalability without loss of quality so this is essential let me show you what's the difference later so first a vector graphic contain a drawing list and then the list contain a command for each object so look at this diagram here um I just made this up to make my explanation clearer there are three objects circle triangle and rectangle so the list contain a command for each object all right and then for each command here let's say I'm looking to the circle they will have the property of what the circle should be so for instance 3080 could be the coordinates as my coordinates and 10 could be the radius how big the circle should be and what color should it be filled and then each command has a list of attributes and then all these properties they can Define geometrical data colors and thickness so by doing this it's very easy for the computer to scale imagine you want this to be two times bigger you don't have to sacrifice the quality you can just say hey can you change this radius to 20 instead so that's the first type of image form so this is exactly what I'm saying in normal images as you scale I believe you all did this in Microsoft PowerPoint a word as the skill the image will find out that the quality is not that good it's more pixelated but for Vector graphic because everything is calculated everything has a property like radius um if you have a cylinder it could be height so this ensures that as you scale from one diagram to another you still get the same quality and the bad thing about vector graphics is that not every image has different shape all right so this is why we have another method to represent image which is called bitmap bitmaps are basically just a bunch of pixels arranging horizontal and vertical line and each box here this is what we call a pixel the smallest identifier component of a bitmap image and under each pixel here they have a binary code that represents what color should this pixel be so this is one example of an image and then each binary code when you convert it into colors this is what you get great and when it comes to representing image using bitmap there's one term that you need to understand it which is colored up colored up is the number of bits used to represent one color meaning how many bits you put inside each little box here if your color depth is one meaning you can only have two possible values zero and one so hence you'll get a white black and white image and as you increase the number of color bits let's say you have four bits now you have four possible value zero zero two one one now you can represent four colors so think about how many colors it can represent in three bits three two one go so using three bits you have eight possible colors which is what I'm showing here all right this is why um but then in a real in Real World what it does is what computer does is that they store 8 Bits in fact 24 bits for one pixel and eight bits is dedicated to one primary color the RGB system if it's for how great it is um it is for how green and another a bit for how blue it should be so this is the I value that a potential pixel could be storing all right and another alternative term for color depth number of bits is that you can also say called beat that all right they basically store how many number of bits um eight number of bits for each primary color and then they'll mix it up to create a unique color all right so and then the resolution in bitmap so now I have another term for you to know for image is the amount of pixel you use for your image and it's called image resolution the higher the image resolution the better the quality it will be and these are the two images I created on canva basically I just hit High one and 100 to 100 and 600 to 600. it basically means I have 100 pixel horizontally and the other 100 pixel vertically and that's that this one is 600. so the better the greater the amount of pixel you use um the better quality of the image will be so if you look at the recent iPhone they say they have 48 megapixels in the camera right so that basically says that they are using 48 million pixels for one images that makes the quality of the image great great so properties of the image I got image resolution color depth and also beat that so sometimes it might be required to calculate how much how big is the size of this image um let's say that I have an image on the right here it has the image resolution of three times three all right so you got three multiplied by three nine boxes and color depth of eight maybe they only use eight bits for one color so they're asking you how what is the size and bytes before that you need to calculate the size and bits and I have prepared formula for you it's very easy just use image resolution multiply by color depth so you should get three times three multiplied by eight and that should be the amount of bits you have but the question asks for bytes so to convert bits to bytes you just divided by eight and the size of this image will be 9 bytes and yeah the other question um this image has a resolution of 600 times 600 and a bit depth of 8. so 8 Bits for each um red green and blue now that's the catch here and what is the size in MIB so first I want anyone to do is to multiply the image resolution 600 by 600 and multiply by 8 and I do another multiplication multiply by three because eight bits is used for each color here so I got in total this amount of bits to convert it to maybe byte I need to convert it to byte first and then convert it again to Kiwi byte by dividing by 1024 and then divide it again to get the answer in maybe byte all right so that's how you do it and that's what we call a bitmap so Vector graphic or Vietnam so which one should you use so opt for Rapid graphic in architectural engineering on manufacturer design so these are the drawing that requires um precision and also great size um they have shapes and for printing purposes you might need to convert your vector graphic into bitmaps so the digital camera so the one that I'm using right now they generate bitmaps of my images like me and then they choose you also need to choose bitmap for embedding images in document publication or web pages so another thing that computer can represent with almost the end of the video is sound suddenly we have learned text numbers and image so now let's look at how sound is recorded as binary as all so let's say I'm talking to this um microphone here so what it first will do is that it will eliminate inaudible high frequency elements to avoid coding issues so if there are voices that human cannot hear they're just eliminate it and they also convert analog data to Digital Data so Digital Data basically means zero and one so let me show you what I mean so when it comes to representing sound if you learn this in physics before you know that there are two properties amplitude and Pitch all right frequency so I have a amplitude graph here that shows how loud a sound should be and our problem now is to how to encode this data into binary okay so what it does is that it will record how loud a particular sound is at a particular interval so let's say in the interval to the three the amplitude is five so you know that five will then be recorded into the computer and it's one-on-one in binary of course the range here is important as I'll explain in the next um slide here the first term for sound is that you need to know what's the sampling resolution of the recording which is the number of bits used to store each sample all right so if I were to use three bits only for my sample I can only have eight possible values right zero zero zero all the way to one one you know that there are eight total value there so and then but if you were to use the sampling resolution for you use four bits to record each sample you can have a better range and the way I always explain to people about how increasing sampling rate solution is great is that imagine that you are in a game and both players have the same level level five all right level five but then these level five players could have different ability one could be better than the other but then because the number of level is only eight so people that have different capability might stuck at the same level because the range is too small but then when it comes to another game let's say they have 16 possible levels so the previously same level players might now have one can be level five and level six because now I have greater range hence I can differentiate them better so by having high sampling resolution you can differentiate between loud sound and louder sound because you have more bits to represent the difference um in Practical terms some computers already using 16 bits to offer sufficient accuracy you can find out the range by using 2 to the power of 16 that should give you like six five five three six yeah if I'm not wrong and another term you need to know is the sampling rate which is how many samples do you take per second in a previous example is how many bits you use for one sample and then the other one is how many samples let's say from one second to two seconds how many samples are you taking you can't just be taking one sample because in one second the voice can change very much for instance ah so in that one second my voice amplitude has changed so much so you have to take multiple samples in one second and how many the num the greater the number of samples you take the better quality of your sound will be but it will also take more storage all right so both high red sampling rate and resolution leads to large file size so that's how we calculate the file size of a sound so you use the sampling rate how many sample you take in one second and how many bits you use for one sample multiplied it multiplied it against by time and when it says um is if a stereo sound is given meaning the left and right speaker you the sound that you hear from left and right so we got different then you have to multiply by two so by using this formula you can calculate the file size of this so I know that something rate I multiply this number by this number and convert one minute to 60 seconds and everything multiply together multiply by 2 again because it's a sterile file and that should give you the size of the image in bits convert it to maybe byte divided by eight to get the bytes first and then divide by 1024 to get a KB byte and again to MB byte so that's that's about it great so now we have learned the how to calculate the file size of sound and also images um it could we could have a very big size of these elements if we don't handle them properly that's why computers like this have learned some compression technique to make sure to sort of shrink the data science no no the data um a little bit making them cost less size so we have two different types of compression method lossless compression in which no data should be lost and everything is reversible once you compress it another one is lossy compression is that you get more decrease in terms of file size but you also lose some information in the process which is not reversible so let me explain one there are two methods for lossless compression this was likely blow your mind a little bit because they are super effective the first technique for lossless compression is the Run length encoding all right remember this is how image is represented you got pixel and inside of each pixel you got number of bits depending on the bit depth of the image so this image if you were to represent it in by binary this is what happened but then what run line encoding do is that they encodes repeated by value by specifying the account and value I looking at this image we have great opportunity for Roe because look the bit here they are the same so instead of storing the same bits again and again why not I just thought one time and the digit four to show the computer that hey I got four um blue color here so by doing Roe this is what happened you only store the num the bits one time and then you stole another bytes here to represent the character four to show the computer that hey I have four copies of blue color here can you see how much this file size has been decreased from 12 bytes so one byte one by one by 12 bytes all the way to six bytes by just using a simple technique so it will also work well with repeated text for instance so we know that you can represent text using ASCII so that's the ASCII code for AAA BBB and then instead of doing this just say I got 40 I got 4B and that is what happened so you have again reduced the number of bytes used from eight bytes to four bytes all right so that's running encoding another way to compress a file is to use the Huffman encoding which is slightly more complicated but not very hot so let me explain what it the principle is that they analyze tags to identify common characters so let's say this is the text then they assign the most frequently character with the least bit so what happened is that you account the frequency of each character in the text so a appeared five times B appeared two times R appear two times I will and so forth and then you create something called a Huffman coding so because a appear the most time um generally you logically you want to use the least bits to represent this character so you're going to do 0 to a b you assign it the code one zero so look this is very similar to the utf-8 one byte so we are assigning this code so that the computer knows when is the starting point and when is the ending point so by creating this table here in fact when I was in university you will learn how to create this table here by using a Python program you can write code to do it for you but because it's not our syllabus I'm just putting out the table for you to see all right just know that most frequently character got the least bit and when you combine them together you have technically um got the file already so if you look at this by machine code binary zero you know that is a and b 1 0 and r110 and so on and so forth great so that's how you represent numbers um Half Men encoding how you compress file great um that's for lossless meaning that nothing is lost throughout the process you still keep all the data but then you have compressive file size by a lot as for lossy compression this one is slightly how I remember it's slightly last year because um some data could be lost but they are lost for good for example how lossy compression compressed sound is that technique one they capitalize on the infrequent change of success with sample value so just like I say that my sound level could change very much in just one second but what if I just do this uh my amplitude could be very similar so I don't have to store this a lot so this is what um the technique does they also convert individual sampler amplitude to amplitude difference so instead of recording like this so the amplitude like that they can use last bit by recording the difference right so instead of recording three and five here they could just record one and two here's so that's a different than by just using the difference instead of the actual value so difference from one point to the other we can use less bit to represent one samples rate um one sample and that will save us some space and for image it's applicable when all right so image they can establish a coding scheme with reduced color scheme because sometimes human eyes just cannot differentiate the many types of for example many types of blue here so after the compression because you want to save size you will just convert it into the same color of blue here and that will reduce the amount of bits used which in turn will reduce the amount of um size you need for your image and I believe that's that's it for chapter one I'm so excited that you watch until now thank you for watching and I'm excited to see what I can teach you in chapter two so that's the end of this video okay I'll see you