 In this video we're going to summarize how to encode natural and integral numbers with base 2 or with binary. So regularly what happens if we use, on a regular days, base 10 encoding. Base 10 encoding means we use digits from 0 to 9 for natural numbers. Computers on the other hand can only work with what we call the binary number, binary system. Base 2, which means we only use digits 0 and 1. Now what we need to know is how to translate a number written in base 10 to base 2 and vice versa. Now the process to translate base 10 to base 2 is using what we call successive divisions. And we do those divisions and the remainders of those divisions give us the bits. The translation on the other direction is by adding what we call powers of 2. 2 to the 0, 2 to the 1, 2 to the 2, so on and so forth. There are two things we have to take into account. First, machines always manipulate certain size in terms of bits. And we have to remember that with n bits we can codify 2 to the n different symbols. This is very important for naturals. Now for integers, for integers things get a little bit more complicated. And what we explore, we're three formats. Format number one is what we call sine and magnitude. And the rules for this representation are the following. We're going to represent numbers always positive. And then we add 1 bit to sign, to represent the sign. And that sign is a 0 for the positive sign and a 1 for the negative sign. So any number, any integer represented inside a magnitude will have its leftmost bit, which will be the sine bit, and the rest of the bits will be the magnitude. And this magnitude will be represented as a binary number. Now one first observation here, we realize that leftmost bit is exactly the same as the sign of the number. The second option we study is what is called once complement. Once complement representation has the following rules. If the number is positive, if the integer we try to encode is positive, then we simply use the regular binary representation as if it were a natural number. However, if the number we want to encode is negative, then the way to obtain the binary representation in once complement is following two steps. First, we encode the positive number as binary, and then step number two, very important, we flip all the bits. And that way we obtain the negative number encode as once complement, as we say here. Now the problem that these two representations have is that they both have two codes to represent zero. Number zero is represented with two codes. This is a property of the sine and magnitude, and it's a property of the once complement. So here comes the third alternative we study, which is two's complement. Now with two's complement, the rules are a little bit more complicated than with one's complement, but they're very similar. Positive numbers are still represented as regular binary numbers. Now negative numbers, we follow three steps. Step number one, as before, we encode positive value using binary. Step number two, as in the case of once complement, we flip the bits. And very important, this is the difference. Step number three, in order to obtain the representation of a negative number in two's complement, we add one to the final representation. Now this code over here has two big advantages. It has a unique representation for number zero, and we can reuse the regular addition. We can add two numbers independently if they are represented as two's complement or regular binary, and the rules of the additions are the same, and the result is correct. Now, aside from these two representations of natural number and these three representations of integers, there is one extra representation that is going to become very handy, which is what we call base 16 or hexadecimal. And analysis of these two, instead of 10 digits as in base 10 or 2 digits as in base 2, we have 16 digits that go from 0 to 9 and from A to F. Now, how would we translate a number in base 10 to base 16? We would do successive divisions by 16. However, dividing by 16 when we apply it to binary is the same as taking the least four significant bits. Therefore, this base is actually going to be used as an abbreviation of binary numbers. And basically what we do is two things. We take groups of four, we start by the less significant bit, and we then translate one group, one digit, in order for us not to get confused with these numbers, between these numbers, these numbers, and these numbers, we typically use the prefix 0x for this representation, a little b for this representation, and nothing for the base 10. And this summarizes the encoding of naturals and integers using binary logic.