To obtain the Page number and Page offset , you need to perform some operation on the address(Virtual address ) which is generated .
- Page number : You divide the address with the page size .
- Page Offset : You have the mod of the address with page size .
And , now to do this you have to select that number which will require less operation and the less number of the operator to do the operation and we know that for doing the divide operator we can use (>>) Right shift operator which is equivalent to the divide with the 2 and for having he offset we need the mod with page size so its basically doing the ( AND ) operation to take the mod .
Example : 12 :→ 1100
Now, assume you have the page size as 8 ( power of 2 )
for divide you only need to shift 3 place :)
for mod you only have to the (12& ( 8-1)) = ( 1100 & 01110 ) = 100 :→ 4 in decimal .
And for doing this operation for having in power of two you need to require less hardware set up in mem and os for calculating the operation . So , that’s why we have the page size in power of two .