We have seen in this page that the powers of two can be used to represent large numbers with sets of bits. One way to do it is by associating the powers of two with the positions of the bits in the set. In this page, we will see how the powers of two work in general.
The power is a mathematical operation which consists in multiplying a number by itself several times, it is represented with an exponent. For example, the power of 3 of a number that we will call n is expressed as n3 and it is equivalent to multiplying n three times by itself:
n3 = n × n × n
In the case of powers of two, the power p therefore corresponds to multiplying the number 2 p times by itself. So for example 23 corresponds to 2 × 2 × 2 = 8. Each successive power therefore doubles the value of the previous one because 2p + 1 is equal to 2p × 2.
The following table contains the values of the powers of two between 0 to 16 (by convention 20 is equal to 1) which are frequently used, you can find here a much larger table with the powers of two up to 21024.
|Power of 2||Value|
The power p of 2, that is 2p, is also used to know how many different integer numbers can be represented by a set of p bits. Thus 8 bits are used to represent 28 = 256 different integer numbers, from 0 to 255 for example.The post Powers of two appeared first on EatYourBytes