# Given the logical address, how to extract the page number?

I am studying Computer Systems. I have th following question and its answer:

Given the logical address 0xAEF9 (in hexadecimal) with a page size of 256 bytes, what is the page number?

Answer: 0xAE (I found this answer in the web, but I want to know how can I figure it out myself?

How can I figure out the page number for a given logical address?

Your logical address is made of 16 bits, that means you have a addressable space of $2^{16}$ bits. The page size is typically a power of 2, $2^n$, in this case $2^n = 256 \Rightarrow n = 8$.

The page number is calculated by substracting $n$ from the size of your logical address: $16 - 8 = 8$, so the first 8 bits of the address are your missing page number, that is 0xAE

Logical address includes both page number and the offset within the page.

Page size as mentioned is 256 = 28. It means that 8 bit address is necessary to address any word within the page. The least significant 8 bits are used for this purpose (as offset address)

The remaining bits (the most significant 8 bits) are used as page number.
So the fist 8 bits specify the page number. 0xAE in this case.

• duplicated answer maybe – Alejandro Sazo May 4 '13 at 23:45

AEF9 converted to decimal-> 1*9+16*15+16^2*14+16^3*10 = 44793

44793/256=174

174 in hexa-> AE

• There is absolutely no need to convert to decimal. AE are the first two hexadecimal digits of AEF9. – Yuval Filmus Dec 18 '16 at 16:01