Transcript for:
Understanding Data Representations in IGCSE

hello everyone welcome to this channel where we will have a brand new series called xero to hero in igcse computer science and in this video what we're gonna do is that we're gonna revise the entire chapter ones of igcse computer science called data representations let's jump straight into it the first topic that we're going to revise today is called a number system all right and the first system that we're going to go through is called the binary system and binary system the reason that we are learning it is because all any form of information here such as text images music they need to conver be converted into a binary format so that it can be eventually processed by a computer which means binary is the only language which a computer can speak in and this is because computer contains millions and millions of tiny switches which can be turned on and off so let me explain therefore binary system is chosen as the way for a computer to represent any sort of data in which when we turn on the switch it means the value want and when we turn off the switch it represents the value zero therefore in binary system there are only two possible value zero and one but think about it um the the basic system that we use in our day-to-day life for instance we have 365 the number of days in a year the number system that we are used to is called the delineary system in which we know that this value is 365 by multiplying the digit value let's say 3 with the place value 100 so we will do three multiplied by 106 multiplied by 10 follow it multiply by one and eventually we got the value 365. and yes this is how we understand numbers in our day-to-day life but as i mentioned computer cannot understand dinner the only language that they can speak in is binary and therefore in this video we are going to learn how to convert binary to binary and binary to binary so that we can input numbers into the computer so that we can transmit data to the computer using the language that they can understand so let us start with by the conversion of binary to dinnery 1011. so how do we convert this binary value into a dinnery value that we can understand and it is very similar to how we understand dynamic system like what i mentioned how we obtain the linear v how we understand then every system is by multiplying the place value with the digit value the digit value the only difference here in binary system is that the place value of each position in binary system is different instead of the the rightmost digit would have a value of one which is similar to the ray system but the second rightmost instead of the value tens we have two which is 2 power of 1 followed by 2 power 4 2 which is 4 and 2 power of 3 which is 8 so on and so forth we just increment the power and to obtain the linear value of this binary all we have to do is to multiply the place value with the digit value so will be 1 multiplied by 8 plus 0 multiplied by 4 all right plus 1 multiplied by 2 plus 1 multiplied by 1 and we'll have to the answer of 11. so let us check if that's the correct answer yes so we have the value of 11 and the way we do this is just by multiplying the digit value with the place value the things that you have to take note here is what is the place value of the first position the second position the third position and so on and so forth each value is multiplied by two in order to reach the next value and to do it the other way around how do we convert a dinary value the value that we all understand into binary a language that computer can understand so we have the value of 39 here and the way that we can get the binary value of this binary value is that we will keep dividing it by 2 keep dividing it by 2 and use the remainder of the division to get our answer so for instance 39 when we divide by 2 we got 19 with as the quotient and 1 as the remainder and if we ever continue to do this 19 divided by 2 we got 9 remainder of 1 4 remainder of 1 2 remainder of 0 1 remainder of 0 and last but not least 1 divided by 2 we got 0 as the quotient and 1 as the remainder to obtain the answer all we have to do is to read the remainder column from bottom to up and by reading it from bottom to up we have we can construct our answer 100 1 1 one and this value here will be the binary value of the the the number 39. so let's check the answer yes 100111 that's how you convert binary to dainery and vice versa next up then the other number system that we computer scientists will care about is called a hexadecimal system and it is a base 16 system in binary we know that there are only two units value zero and one therefore it is a base two system and and in general we have the value from zero to nine as you can see for in this table in which it is a base 10 system because it has 10 units value binary only 0 and 1 and in hexadecimal there are 16 values first up from 0 to 9 and it's not followed by 10 but instead it's followed by character which is a to f so in hexadecimal the unique values are range ranging from 0 to the character f in which a is equal to we have a table here which map binaries into hexadecimal and binary as you can see a in hexadecimal is 10 and dinary and b to 11 so on and so forth this table is important you might need to construct it during your exam to do the following question which is the conversion of binary to hexadecimal and hexadecimal back into binary so imagine this is the binary value that we have 10111001 and the way we can construct the hexadecimal of this binary the first step is to split the binaries into a chunk of four all right so we have three chunks here first chunk second chunk and third chunk and using the table that i introduced just now we can map this chunk of binaries into their respective hexadecimal value so let's find 0 0 0 1. if we look at the table it is 1 in hexadecimal it's 1 in hexadecimal so i just put 1 here and 1 1 1 0 we have the value of e so we put the value e here sorry for the bad handwriting and last but not least 101.1 we have the value of b so the full answer of this binary is b e 1 so that's how we got our final answer easy right that's why one question for you is that in the exam you will have to construct this table by yourself it won't be given so it's it's important for us to construct this table by ourself right so let's look into the other question in which it's the same type of question but here we have 14 digits in binary instead of 12 so that when we split this chunk this binary into chunk we got the we got four chunks all right and however the leftmost chunk as you can see only has two digits but we cannot find one zero in our table here so what do we do so in this scenario what you have to do is that you can just add the leading zeros to the value so that you can refer this value back to the table so like by mapping these binaries into the table we get the value of um 2 1 f d feel free to check out the table to see if there's any mistake right so the final answer of it is 2 1 fd in hexadecimal so let us do another question this time is the other way around in which we convert the value the hexadecimal value back to binary so i guess you might have already know how to do this again we map those values back into their respective binary value which means we are referring from the right column to the left column so the value f we have four ones all right the value nine we have 1001 as you can see here all right three we have the value 0 0 1 1 and five we have the value zero one zero one and all you have to do is just concatenate all the string together to form our final answer here so that's how you can convert hexadecimal to binary in my opinions they are the easiest question that you can see in the exam all right so next up the last two conversion that we need to do in this subject is to convert hexadecimal instead of to binary we're going to convert it into denarii and vice versa so the method to do this is very similar to how we convert binary to generate if you remember remember the way we convert binary to generate is that we multiply the digit value to the digit value here to the place value here off right okay so in hexadecimal the only difference is the place value so we the rightmost digit place value is still one but the next value instead of 10 instead of two it is now 16 remember half the decimal is a base 16 value so we got 16 power of one we got 16 and followed by 256 it's gotten it from when we multiply 16 two times 16 to the power of two and again now we can do the basic thing but before that we have to remember that in half the decimal there there are some characters so before we do our conversion we do need to convert this character into value for instance a we need to convert it into the value 10. so we can just do the basic stuff by multiplying the place value with the digits value and we have gotten our answer here okay feel free to try it yourself yourself so next next step we're going to convert daenery into hexadecimal and the way we do this is very similar to how we convert generated binary if we remember the way we convert the value 5 to binary is that we keep dividing it by 2 we have the remainder we read the remainder from bottom up okay so so we have an example here how do we convert the value 2004 into hexadecimal value so instead of dividing the value by 2 which is with occurs in binary we will divide it by 16. and if we were to do this 2004 when we divide by 16 we got a value of 125 as our quotient and 4 as our remainder so we just write the value back into our tables here and let's continue to divide this 125 by 16 we'll get the value of 7 remainder of 13 but remember in half the decimal there is no value 13 13 is represented by the character d all right and so on and so forth we just divide 7 by 16 we got 0 as quotient and 7 as our remainder to construct it we read the remainder from bottom up and we'll have the value of 7d4 so 13 is equivalent to the value d in hexadecimal and that's it that's all the conversion problems that we need to do all right feel free to rewatch certain part or comment if you have any doubts on how to do this question i will try my best to answer it and next up having learned about the hexadecimal system we are going to have a look on what are some of their usages in computer science why do we need them if we already have the binary system and just look at this diagram the binary value here is corresponding hexadecimal value is this okay i would i won't do the conversion part you guys can try it yourself and there are two reasons why they are used the first one is as you can see has the decimal is easy for us to visualize all right there are a lot of one and zero here in binary it would be difficult for programmers or computer scientists to read data in this way instead it's easier for us to look at the hexadecimal value which leads us to the second advantage of hexadecimal which is it is more compact and shorter remember four binary digits is equal to one hexadecimal value so that reduces the length of the data by four times when we use hexadecimal all right so there are four usages of hexadecimal system the first one is arrow codes in which it tells the programmers where the arrow is located by putting up all this um hexadecimal value if you can see here these are all hexadecimal values so that's the first usage of hexadecimal and the second usage of has a decimal system is the mac address mac address is basically an identifier for your device like laptop and smartphones we'll go into that more in details than chapter three so as you can see the mac address of a device feel free to check your own mac address in your computer um they are also represented in hexadecimal and the usage of hexadecimal is called is the ip address which is given which is an address given to a device when it is connected to a network so for instance an ip address it could be represented like that see the rep bracket in hexadecimal instead of in delivery okay so the last usage of hype of hexadecimal system is called the html color code html is basically a a language that programmers use to develop website it's not a programming language but a markup language so when you're making website there are certain colors that you might want and you would encode this into your in hexadecimal all right so to summarize so because this is a very commonly asked exam question in igcse i therefore i use the mnemonic to help me unders to help me memorize the full usage of hexadecimal system called the ime so e stands for error codes m stands for mac address i stand for ip address last but not least html color code all right having talked about hexadecimal system let's move on to the additions of binary's value how does computer carried out additions for instance in our calculator apps how do they multiply values and add values so this is what we're going to look into the next two segment so if you remember how we carried out dinner how would you carry out addition in scenery is that using this um old school method here all right let me change another color for this background so this is how we perform addition in the system so 9 plus 1 we have the value 10 so 10 is our value residual value and 1 is our carried over so we have but in binary it's a little bit different if you remember binary we only have two unique values so if we were to add zero and zero we obviously we're gonna get zero zero two plus one we're gonna get one one plus zero we're gonna get one again but if we were to do one plus one remember in binary there are there's no value called two what it will do is that one plus one is equal to one zero one plus one is equal to one zero and how it works is that when we use one plus one we'll get zero with a carried of one because one is the maximum value in binary and we just bring this carry down that's how we get the value of one zero if i were to add one plus one plus one i will get the value of one one it's not eleven it's called one one which is 1 plus 1 plus 1 if i were to do it here we get 1 with the carry of 1 okay so that's how we add binary values and let's try out an example here how do we perform at in this in this example so we could you can just go through with me one plus zero we got the value one one plus one we got the value of one zero so our value here is zero with a carry of one and move on we have one plus one and we'll get one zero again so again zero with a carry of one one plus one zero with a carry of one one plus zero plus zero we get a value of one with no carry one plus zero one zero plus one one so that's all that's how we convert this value into that's how we add two binaries numbers together so that's the answer and here i want to introduce another condition called the overflow condition it might happen so let's do this edition again you can pause the video to try it yourself zero plus zero we got zero we have the one plus one one zero one plus one plus one one with carry of one again one carry of one zero one zero carry of 1 1 plus 1 1 carry of 1 0 1 plus 1 0 c we we have generated 1 plus the ninth value 1 plus nothing we get the value of 1. so we when we add these two binary numbers together we have generated an extra an extra digits here an extra one value here okay what is the big deal of this right this is we care about this thing because when we are learning about hardwares we know that certain that the component that stores this value is called register and sometimes register might have a fixed size what if the val the register that stole this value only can store eight binary bits if this happens the extra bits that are generated here will be oh let me adjust it the extra bit that i generated that's generated here will be lost all right if i to do this all again so this is the value that we'll get so let me clear my drawing right let's see so the overflow condition is when a knife bit is generated this means that the value the summation the value the result of this summation has exceeded the value that the eight bit binary numbers can store and eight bit binaries numbers here we have eight ones here if you check the value of this is 255. but we know that when we add two numbers together there is a chance for the result of this summation to exceed this value and this is how the knife bit is generated this is called an overflow error which means there is a risk that this extra bit generated here the green color one will be lost the sum is too big to be stored using just eight bits okay so that's how we do addition and the overfill problems that we might face when we do this um in the idris actually exam they might ask they might give you just two binary numbers and ask if okay does overflow problem occur you have to answer this yes and give the reason of it why because the knife bit has been generated so having learned about how to add binaries numbers now we'll move on to how do we multiply and divide binary numbers think about it it's necessary that there is a plus and divide functionality in your computer right so that's less than how do we do this it's the method that we use to multiply and divide binary number is called binary shifting binary shifting in essence we are basically shifting the binary numbers so let me give you an example here so we have the binary value one one one here and one one one in dinner we we can just multiply you use back the method that we learned multiplied the place value by the digits value which we will get the value of seven here we'll get the value of seven okay so let's try to shift this binary value one one one to the left in which we will move each digit one one place to the left all right so when we move one one one to the left we got one one one zero instead and i want you to observe this the effect of this shifting so from the table we know that the identity value is 8 plus 4 plus 2 in which we get 40. all right hopefully you are starting to observe some pattern here so let me just move this binary one more places to the left so one more places to the left we will have one one one zero zero and in dinary this value is 16 plus eight plus 4 in which we'll get the value of 28. all right can you observe a pattern here when we shift the value of the binary to the left by one digits the the value of it is actually multiplied by two and if we were to shift it again we'll multiply it by two again so so that's the pattern of it is that when we shift binary value one place to the left we are multiplying by two if we were to shift it two places we are multiplying by four three places we multiplying by eight and by following this pattern if we were to move n places to the right we are multiplying the value by two to the power of n okay if you can see here when we move one place we got the value two which is two power of one when we move 2 please we got 2 to the power of 2 which is 4 when we move 3 places we got 3 to the power of 3 which is 8. so this is how we multiply a binary value we shift the binary value one place to the left and to do division we can do the exact same thing but we are we just change the direction of the shifting so for a cpu to divide a binary number the numbers needs to be shifted to the right so that let me give you an example here we have the binary value 101100 so the value here the binary value of this binary is 32 plus 8 plus 4 will have the value of 44. so if i were to shift this value one places to the right so i'm going to move this to this here to here here to here here to here here to here and i'll get this the result here all right every digit being shifted to the right and if i were to calculate this value in binary it is 16 plus 4 plus 2 and we get the value of 22. and if i just shift this one more places i will get 1011 all right and if i were to calculate the linear value of this is 8 plus 2 plus 1 which will get 11. so from the value here hopefully you can see the pattern 44 to 22 is division of two 22 to 11 is again division of two so the same theories persist 10110 oh if i to shift one place to the right it's division by two 2 4 3 places divided by 8 and the formula if i were to shift n places to the right i'm actually dividing the value by 2 2 to the power of n so okay so here they say that register contained within the cpu register is a component that stores all the bits that the computer needs we'll talk more about it in chapter three and and sometimes this register the amount of data that can hold at one time is limited because the number of bits that they can store is limited therefore the multiplying shifting effect multiplying shifting effect can cause bits to be lost at one end of the integers and they were added at the opposite end this process is known as losing the most significant bit so think about it this is the value that we have one oh imagine this is the value that is stored in a register if i were to shift this binary value one place to the left so i would get 1011000 but my registers can only store eight values that means it can only keep the values here so this values will be lost and we call this scenario losing the most significant bit which can have an effect on the some the result of the multiplication so we have to be aware of this problem so this is how we multiplied and divide binary value so let's move on to two's complement which is a number system that helps us to represent negative number so a processor can also represent negative numbers such as negative 5 negative 100 and one of the method that a process can represent negative numbers called the two's complement it's very similar to binary system but with a slight twist so to wrap before we start the conversion learning the conversion we have to take note of this as that in two's complement if the starting digits starts with the value of zero this means that it is a positive value and if the leading bits is one this means that it is a negative value for instance let us have this value in two's complement without having to calculate this we know that this is a positive value because it's leading value its leading bit is zero and on the other hand if i were to have a value like that without calculating it we know that this is a negative value because it has the leading beta of one so let us try to see how we convert this which i believe this is a new syllabus and igcse computer science it doesn't appear in a lot of positive papers so do pay attention when you're learning this so there are four steps that involve in converting this binary negative thinner value into two's complement so first of all we just have to convert this value number into positive so negative 67 we just have to convert it into the value of 67 and step two we have to write the number in binary form what is the binary number of 67 so just to revise um this is how we do this we keep dividing it by two and we get the remainder 33 um we got the remainder of 1 all right so 33 divided by 2 we get 16 and remainder of 1 and do it again and again until until we divide the number two until the quotient here becomes zero okay so two divided by two we got one zero as the remainder one divided by two quotient becomes zero and one so our binary value should be 1 000 1 1. so this is how we can do this so one catch here is that if you were to do this remember if your binary value is seven digits remember to add the leading zero this is very important first to find the two complements of this scenario value remember to add the leading zero if your result is less than eight bits so having calculated these values the next step is to invert each binary value in which we change one into zero and zero into one so zero to one so we got one zero one one one one derivative we are basically inverting the binary digits and instead of step four by using the inverted value we add this binary number by one and we'll have the result of 101101 and that's the end of our calculation we have gotten the two's complement of negative 67. so this is our final result okay so let's try to convert um another value like 65 you can try it yourself right this is how we do this the four-step summary we convert the value into positive we obtain the binary number we invert the digits we mult we plus one and eventually we get our final result okay the five steps that we have so let us try to do things the other way around let's try to convert this two's complement value into a negative identity so without having to calculate everything you would have known that this value here is a negative value negative value the reason is because the leading digits of this two's complement is one and how we do this is very similar to how we convert binary to dinnery with one catch is that the place value of the last move value instead of what negative 128 is is instead of 128 sorry it's negative 128. and which we can just multiply the digits value here with the place value and sum them all up together all right so that's how it is done when we convert and this is how we obtain the negative identity all right so that's how we can represent negative value in binary into a complement and how we can do things the other way around okay so so far we have learned how to convert different numbers into binary into a value that computer can understand but we know that computer can receive data not just in numbers but also in other formats such as text images and sound so the next topic that we have here is how how do we represent text sound and images if the computer can only understand binary how do we encode this information into a language that into the only language the computer can understand let's start off so that's um how we will see all this at components let's say in a game called fortnite we have images text and music so let's start out with text here they say that every character that is input into a computer must be represented by binary code which means every character that you are seeing now on youtube on your google word such as abcd they are represented by some of some mysterious i would say binary code even including the space and punctuation that we type in therefore it is important they say point number two that computers have a common set of characters that are recognized by a variety of system which means given a binary like 10101 the computer has to understand that this bunch of code represents a character let's say a all right so the the the method that we use to map binary into character is called the character sets and the two characters said that we will that we will learn is firstly it's called the ascii code and the second one is called unicode so let us look at this images here it is the ascii code table in which you can see that each letter here each letter here is represented by a certain binary for instance the binary 0 one one zero zero zero one represent the character a so now so on and so forth and by using this method the computer can understand okay okay the character that we are typing is called a because it can reach the binary in zero one one zero zero zero one okay so that's how computer can read text this is called the ascii code um the other methods the other character says that they are commonly used nowadays called the unicode and this is because the extended the ascii code is not enough if you look here um we only have eight bits here okay we know that the number of represented representation 8 a 8-bit binary can have is there is a limit to it it's only 225 characters which means ascii code can only um adapt to 255 unique character but we know that as we will type different languages into our computer such as friend mandarin we need more character we need more digits so that's why unicode is invented it uses 16 bits instead of 8 bits to represent character in its set which enables over 65 thousands over characters and these characters can be the emoji that we use day-to-day okay so the two ways that we learn here which a computer used to represent text is called firstly the ascii code and also the unicode so let's move on to sound and they say here sound can also be represented in binary the voice that you are listening now my volume there can also be represented in binary and the way they do it is for a computer to successfully process sound the analog signal input has to be converted into a digital sound sound will be captured for instance it will be captured by a microphone here that i have and a piece of software will then capture it and convert this sound into digital digital data means zero and one and this recording this is the first keyword that we look into is called a sample the voice that they record is called a sample and how sampling is used to produce a clip so this these are the three steps first of all the amplitude how loud my voices is which determine at set intervals this gives an approximate representation of the sound wave and each sample of the sound wave is then encoded the keyword as a series of binary digits for instance here we have a sound graph here which record how loud the void is at a particular time so one two three four five six and each in time interval the amplitude will be quantified so the range that is used in this graph is from zero to nine so we know that zero n9 can be encoded into binary so that's how computer can read sound and this if i we in point number two they said that if we were to increase the number of possible value used so instead of zero to nine if i were to increase this into zero and one thousand which means i and long elongates the range this will increase the accuracy of the sample song because the range is bigger now but everything comes at a cost if i were to record um if i were to increase the range this means that the number of bits used to represent this sound will have to be increased so this is called the sampling resolution in which it is the number of bits here you have to remember this definition the number of bits used to represent sound amplitude in digital sound recording which also known as bit dap bit that that's the equivalent of sampling resolution in other words if you were to increase sampling resolution you increase the accuracy of the sound which means your sound will be of greater quality so that's how sound is represented and a recording software here is also capable of taking multiple samples every second this is measured in hertz where one hertz means one cent per per second all right if i were to record my sound in um i want three samples per second it would be three hertz so that's here's another definition here called the sample rate then which is called the number of sound samples taken per second all right so that's all about sound the tree definition that we have here is firstly the sample second one the sampling resolution what is the number of bits used to represent the amplitude of my sound alright the one is the sample rate how many samples do i take per second and here are the pros and cons of using a higher sampling rate or larger resolution which is if i were to use more bits to represent the amplitude of course the size of it will be bigger produce larger file size but it will also have larger dynamic range better sound quality less distortion and the drawbacks of it is larger file it takes longer to download the file and requires greater processing power and it is a very commonly asked question in the exam so make sure you you understand all this benefits and drawbacks so that you can evaluate accordingly in your exam okay so next up having talked about how computer represent text how they represent sound we'll move on to image image every image that you see now even the video that you are seeing now is actually represented in something called a bitmap a bitmap which is literally a map of bits that forms a particular picture video is just a series of pictures and when rendered to display like a computer monitor an image is made up of two-dimensional the horizontal exists and the vertical axis and each pixel is stored in the computer as a series of binary numbers and here we have a very cute puppy and this image is also represented in pixel to simplify it i draw a five to five pixel here so this is they have five vertical bar and five horizontal power so this is a five to five image okay so let's look at some of the image so as i said computers can only understand binary so this means that each pixel here they are actually just a bunch of binary value they're just a binary value in which each binary value here represents one color okay so here we have so imagine that here i only use two digits only new sorry one bit to represent one pixel this means that my image can only be black and white because if i only have one digits the value that i can have is either zero or one it can be either or one that means i can only have black and white which means if this pixel is called s0 has the value of 0 the computer will represent it in black color however if i were to increase the number of bits used in each pixel let's see if i were to increase it so imagine if i use two pixels i mean two bits in one pixel i would have four possible value zero zero zero one one zero one one and i can assign each code here into one unique color color 1 color 2 color 3 color 4 which means if the number of bits that i use to represent 1 pixel is 2 bits i can have an image of delta into the four colors so as you can see in this image there are four colors here one two three four so the number of bits used to represent each pixel is only two bits and if i have to increase it to three bits i would have eight colors and here i will introduce a new terminology which is called the color depth the color that is the number of bits used to represent each sorry each color each yeah each color called it's called the color that so in this image here if i were to use three bits to represent each color my bit my color depth will be equal to three to three so so like what we should see if i only use if my color depth is one bit i would only have two colors if i have two bits might have two four colors three eight so what about eight bits right we need a formula to calculate this and the formula that we can use to calculate the number of colors we have is two to the power of number of bits all right number of bits if i have two bits here or use two to the power of two as you can see i can would have four colors um however in modern computers that we are using now they usually have 24 bit color depth which means they can produce over 16 different colors 60 million different colors all right so that's how computer can produce a variety of colors less image and another term that can affect the quality of an image is called an image resolution which is the number of pixels that makes up an image so try to look at this diagram from a to e the rightmost image here it has the least resolution lease resolution which means the number of pixel number of boxes that form the image is the least this is why it has the lowest quality all right however if you look at the leftmost images it is the clearest because it will have it have a higher image resolution more pixel to represent that image so this is the definition of image resolution the number of pixels that make up an image so another picture here so um again they are what are the cons of using a high resolution image what if i want to have a higher quality image this is pretty common sense which the first one is the increase of file size because the more pixel that you have the more binary bits that you will need to store and greater the size the longer it is to download the image and then point number three a certain amount of reduction in resolution is possible before the loss of quality become noticeable which we will touch more of this in data compression so now we'll move on to how we measure the size of certain data in computer how does computer measure how many gigabytes kilobytes that the file has so let's first learn some of the basic terminology of star and storage and computer science the first one is called the bit the bit which is 0 and 1. so this is how computer stores data it is the basic unit of all computing memory storage tim and it's either 0 or 1. and move on we have the terminology of byte it's the smallest unit of memory in a computer which every eight bits here like you see here is called one byte one byte so if i were to have zero one one zero one one zero zero stored in my computer my computer will calculate this as a one byte because it's equivalent to eight bits and another terminology that you have to remember is called the nimble which is half a byte um four bits all right so that's the basic terminology um but we know that um computer can store us a lot of bits therefore a better organization system is needed which we will learn is called the iec base 2 system of units where 1 kilo is equal to 2 to the power of 10 bytes which is equivalent to 10 1024 bytes so by cat by using this we can write we can name the bytes better instead of saying i have 140 800 48 500 bytes i can just say the size of it is 1 mb byte it's easier to visualize and also easier to pronounce it all right so let us try to convert this bytes into qb byte maybe byte and gb byte the way we do this is very simple first of all um if i were to convert bison to kb byte we just have to divide this value by 1024 and the value that i have here will be the value in kb byte what if i wanted to be maybe by instead all i can do is just to divide it again by and twenty four will have get the value in media byte if i want gb by i'll get um again divide by ten thousand and twenty four i would have 64 gb byte all right so that's how we convert bytes into the different units that we have and to do this another way around as you might have a guess is that we just have to multiply instead of dividing it just multiply by 2024 and get the value all right so that's how we restored how we convert gb by to the different units that we have here okay so let's do some exercise which can help us to calculate how big a size an image is and and also audio so let's start off with image how do we calculate the size of image so there is a formula here which is to calculate the size of an image we just have to use the image resolution pixels and multiply by the color depth and the form the way we can derive this formula is very straightforward so imagine that we have a two by two image here and we have a color depth of two and as you can see here oh the way we can calculate the size of this image is to first determine how many blocks there are one two three box which we can get it by multiplying the image resolution two by two we have four boxes and each boxes we need to know how many bits are there in each pixel and here we have two so the formula is image resolution by color that so we are basically calculating how many bits are there in this image and we can just use four multiply by two we'll get eight bits so as you can see this is the image resolution image resolution and this is the color type and the size of it would be eight bits all right eight bits which is one byte so this image the size of it is one byte so let's move on to a real exam question image resolution let's say i have an image of 2048 times 2048 with a color depth of 16. i can just use the formula the image resolution multiplied by color size and will have gotten the values the size of it in bits but note here the the question said i want the size of this image in bytes therefore one more step is needed here which is we need to divide by eight to obtain the storage size and by the story size and byte okay so that's how we get our answer so so that's how we calculate the size of an image all right it's pretty straightforward and let's move on to how we calculate the size of a sound and the the way we calculate this is to use this formula first is that we use the sample rate multiplied by the sample resolution and also the length of sample in second so let's look at one example question imagine that this is the question they said um they say that this is a modal sound and they give you some semperate sampling resolution and length of this music in second and they said they want the size of the audio in kiwi bite so let us try to use this formula we'll have get gotten um seven millions bits okay but since the question says they want the answer in kiwibyte we need to first convert it to byte and the way we do this is to divide the number of bits by eight and got the bytes and to convert bytes into kbyte we have to multi we have to divide it by 1024 so this is how we got the final answer it's 861 kilobyte kiwi by so that's for mono sound another question they might ask is that they will sit here we have a stereo sound so um let's read the question and order cd has a sample rate of four to four thousand let's highlight the important details all right sampling resolution of 16 bits and the music sample uses two channels to record for stereo recording stereo recordings means if you were to bring um your headphone the left and right headphone will have a different voice that's called serial recording and calculate the file size visit for a 16 minute recording so there's a catch here remember the formula is sample rate multiplied by sampling resolution and multiply by time but the time should be in second so therefore we need to convert this length into second which is 3 600 second so here the way we can do this is just to multiply everything together all right 44 000 and so on you'll get number of bits but here's the catch here because this is the stereo sound we need to multiply the value that we have here by two so we need to multiply the number of bits by two this is only needed needed for stereo if it is a mono sound file it is not needed okay so that's how we just have to divide it by 8 to get number of bytes and eventually multiply by to get the file size in maybe byte so that's about it for how we calculate file size in images and in sound and let's move on to the last topic of this video called data compression so like what we know just now oh we see just now if we want to have a very high quality image or sound we need to increase the number of bits we need to increase the color that the sampling resolution which would result in an increase in size and there is a way that we can compress all these files so that we can retain the information but losing some of the storage size so let's see how we can do this how we can compress the data just like in this animation here and like what i said file size of images and sound can be very large therefore we need to do something called the data compression it is very equivalent to the zip function in your computer if you notice so um here are some of the benefits that um to reduce the file size the first thing is that we can reduce the streaming time which means if this video size is smaller it is easier for me to upload it to youtube and videos time taken to upload and download media reduce cost cost is very important if you go to the market and try to look for a 128 gigabytes and 256 gb of hard disk you will know that the price is very different therefore by reducing the size we can actually reduce the cost and save storage space very straightforward so there are two different types of data compression that can be carried out um especially for what we will learn in our syllabus the first one is called the lossy file expression compression file compression second one is called the lossless file compression so let's start off with the lossy file compression it is a an algorithm that eliminates unnecessary data from the file and one setback of it is that the original file once you have compressed it it it cannot be constructed reconstructed all right and some of the lossy file compression algorithm that we'll learn is the mpact3 the mpeg-4 mp4 and also the jpeg okay so here are some of the details of mp3 it's a compression technology that reduces the size of the normal music size followed by 90 and the way that it does that is to it removes sounds outside the human ear range which means when we record a sound there is certain sound that cannot be heard by earth but they pick up some of the storage space so this algorithm they remove all the sounds that we cannot hear and they eliminate look at point number two the softest sound that we we can't hear all right so um that's mp3 so mp4 is a lot of storage of multimedia file rather than sound and the secret of how you compress file is that it um removes certain pixels in in the algorithm in the video without us noticing what is different that's for video and jpeg is for as for the image it will reduce color shades that we cannot notice so um so this is how we reduce the size of image and sound so if you remember how we calculate the formula for to calculate the size of image as image resolution multiplied by color that multiply by color depth which then will give us the size therefore if today i asked you how do we reduce the size of an image there are literally only two methods first of all we reduce let me use another color we reduce the image resolution or we reduce the color depth of the image so that's how we can do this this is i think i believe is a positive exam question they said how does lossy file compression reduce the size of an image so that's the two methods that you can use reduce the resolution reduce the color then and another let's move on to like the formula of to calculate um a sound which is sample resolute sample rate multiplied by sampling resolution multiplied by time all right okay so the way we can reduce the file size of a sound again is either we reduce the sample rate or we reduce the sampling resolution or we can even reduce the length of the video to reduce the size okay so that's how this all these things can be linked together so um having talked about lossy file compression the way that i remember this type of file compression is that um instead of lossy i call it lousy because once the file size is being compressed once the file is being compressed it cannot be reconstructed it is very lousy but here's another data compression method which is better than lossy compression which is called the lossless file compression as implied by the name once you compress it you won't lose any forms of data it's lossless you won't lose any and all the what they say here all the data from the original uncompressed file can be reconstructed once you compress it from let's say you have a file you can press it cf compress file you can reconstruct it back to f this this is important because sometimes when we compress well we don't want to lose out some information important information such as um let's say you are working on a very complex spreadsheet for your company you don't want to lose certain data okay it is it's a compression algorithm that is designed so that none of the original details are from the file is lost okay so one type of algorithm that do lossless file compression is called the run length encoding so what it does is that it is used for compression of numbers of different file formats it reduces the size of a string of adjacent that's the keyword and identical data all right a repeated string is encoded into two values let me give you an example here say um let's say we have the data here we have five a's four b two c five d concatenated together and they are just identical of each other and they are adjacent of each other and how run length encoding would do would do is that um so the file size here will be 16 bytes assuming that each character is represented by 8 bits but there's a way for us to further compress this file so let's say we can actually encode instead of encoding five character a here we can encode number five the number five and with the digit the number value that represented eight so this means that instead of us using five bytes here two bytes here is enough to represent the same information all right so if i were to continue here so let me clear my marking so here we we only need eight bytes for for each digit so one two three four five six seven eight instead of the 16 bytes that we have there so we have reduced the file size by half of it without losing any important information however runland encoding is only useful when your data is very identical to each other okay so and if you were to continue your studies in computer science you would have learned many many different file compression algorithms which are much more advanced and efficient and here we have finished the entire chapter ones of data representation for igcse computer science so we have talked about a lot of things such as number system how we represent texts found sound and images in computer and we also learn how to calculate file size and last but not least we end the video with data compression and i hope that this video will help you to revise better and hopefully you'll get a better result in your exam so that's the end of this video thanks for watching see you goodbye