Page Offset Calculator
Enter a memory address and page size to find the exact page offset, page number, page base address, page end address, and number of offset bits.
What Is a Page Offset?
A page offset identifies the exact byte position of an address within its memory page. When an address space is divided into fixed-size pages, each address can be separated into a page number and an offset inside that page.
For a page size of 4096 bytes, every page contains byte offsets from 0 through 4095. An address located at the beginning of a page has offset zero, while the final byte in the page has offset 4095.
How to Calculate Page Number and Page Offset
The page number is obtained using integer division, while the page offset is the remainder after dividing the address by the page size.
Page Offset of Address 0x12345 with a 4 KiB Page
A 4 KiB page contains 4096 bytes, which is
0x1000 in hexadecimal.
Find the Page Base and Page End Address
Once the page number is known, the beginning of that page is found by multiplying the page number by the page size.
The inclusive final byte address of the page is the base plus the page size minus one.
How Many Bits Are Used for the Page Offset?
When the page size is a power of two, the number of low-order address bits used for the page offset is the base-2 logarithm of the page size.
A 4096-byte page is 2¹² bytes, so the lowest 12 address bits
represent the page offset. An 8192-byte page is 2¹³, so it
uses 13 offset bits.
| Page Size | Bytes | Hex Size | Offset Bits | Maximum Offset |
|---|---|---|---|---|
| 1 KiB | 1,024 | 0x400 | 10 | 0x3FF |
| 4 KiB | 4,096 | 0x1000 | 12 | 0xFFF |
| 8 KiB | 8,192 | 0x2000 | 13 | 0x1FFF |
| 16 KiB | 16,384 | 0x4000 | 14 | 0x3FFF |
| 64 KiB | 65,536 | 0x10000 | 16 | 0xFFFF |
Calculate a Page Offset with a Bit Mask
For a power-of-two page size, the page offset can also be obtained using a
mask equal to pageSize - 1. The low-order bits selected by
this mask are exactly the offset bits.
Page Number vs Page Offset
The page number identifies which page contains an address. The page offset identifies the byte position within that page. Together they describe the original address relative to the selected page size.
For address 0x12345 using 4 KiB pages, page
0x12 contributes 0x12000, while the offset
contributes 0x345. Adding them reconstructs
0x12345.
What Happens When an Address Is Page Aligned?
An address is page aligned when it is an exact multiple of the page size. A page-aligned address always has a page offset of zero.
Bytes Remaining in the Current Page
The calculator also reports how many bytes occur after the selected address before reaching the inclusive end of the current page.
If the offset is zero in a 4096-byte page, there are 4095 byte positions after the current address. If the address is already the final byte of the page, the result is zero.
Page Number and Offset Examples
| Address | Page Size | Page Number | Offset | Page Base |
|---|---|---|---|---|
| 0x12345 | 4096 | 0x12 | 0x345 | 0x12000 |
| 0x1ABC | 4096 | 0x1 | 0xABC | 0x1000 |
| 0x10000 | 4096 | 0x10 | 0x0 | 0x10000 |
| 0xFFFF | 4096 | 0xF | 0xFFF | 0xF000 |
| 0x12345 | 8192 | 0x9 | 0x345 | 0x12000 |
Page Offsets in Virtual Memory
Operating systems commonly divide virtual address spaces into pages. A virtual address can conceptually be separated into a virtual page number and an offset within that page.
During address translation, page-table structures are used to determine the corresponding physical frame. The offset identifies the location inside the page and normally remains the same when the virtual page is mapped to a physical frame of the same page size.
Why 4 KiB Pages Have a 12-Bit Offset
A 4 KiB page contains 4096 bytes. Because 4096 equals
2¹², twelve binary bits are required to select one of the
4096 byte positions inside the page.
Therefore, with 4 KiB pages, the lowest 12 bits of an address are the page offset. All higher-order bits form the page-number portion of the numerical address decomposition.
How Page Size Changes the Offset
Increasing page size increases the number of bits assigned to the page offset. As a result, the same address may have a different page number and offset when interpreted using another page size.
For example, 4 KiB pages use 12 offset bits, while 8 KiB pages use 13. A 64 KiB page uses 16 offset bits.
This is why the page size must always be known before interpreting an address as a page number plus offset.
Where Page Offset Calculations Are Useful
Study page boundaries and decompose virtual or physical addresses.
Determine the location of an address relative to its current page.
Work with page-aligned buffers, mappings, allocators, and low-level memory.
Identify page boundaries around addresses shown by debuggers or memory tools.
Practice page-number and offset calculations used in virtual-memory concepts.
Reason about positions and alignment relative to page-sized mapping units.
Large Address Support with BigInt
Memory addresses are integer values, so page calculations should not lose precision. Ordinary floating-point numbers cannot represent every sufficiently large integer exactly.
The calculator uses JavaScript BigInt for the address, page
size, page number, page base, page end, and page offset. This keeps all
arithmetic exact.
The page-size validation is also performed using integer bit operations, ensuring that the supplied size is an exact power of two.
Common Page Offset Calculation Mistakes
Using the address divided by page size as the offset
Integer division gives the page number. The remainder gives the page offset.
Using the wrong page size
Page decomposition depends directly on page size. The same address can belong to a different numbered page when another size is selected.
Confusing page offset with memory offset
A general memory offset is the difference between two arbitrary addresses. A page offset specifically measures an address from the beginning of its containing page.
Forgetting that page offset starts at zero
The first byte of every page has offset 0. The final offset is page size minus one.
Assuming every page size is valid for bit masking
The simple address & (pageSize - 1) technique requires a
power-of-two page size. This calculator therefore validates that condition.