Question

I have a pretty elementary question which is somewhat confusing me. It will be great to get some refresher on this.

Every computer has a word size. The word size is the maximum size of the virtual address space. So if we have lets say a 32 bit word size, we have a virtual address space that ranges to a max of 2^32 values. In references it says 2^32 bytes? Why is the range in bytes.

Also, What I am failing to understand is how 2^32 possible values be a possible address range of 4GB? So, my confusion stems from the confusion of turning the 32 bit word size into 4 byte word size, and then how 4 bytes, multiplied 2^32 times result in 4GB.

One way I tried to rationalize it is as follows:

2^32 bits = 2^2(bytes) x 2^10(kilobytes) x 2^10(megabytes) x 2^10(gigabytes)

So successive division of 2^32 by 2^10 results in 2^2 GB or 4 GB.

Can somebody point out how the 32-bit word size go to a 4GB page range?

Thanks

Was it helpful?

Solution

The argument in my head goes like this: We have 32 bits available to us, each bit can be at most 1. So the largest number we can accommodate is when all 32 bits (the 0 bit to the 31 bit that is) are filled with 1s. So the trick is to find the largest number in decimal form, by converting from binary to decimal we get:

1111111111111111111111111111111 (binary) = 4294967295 (decimal)

But what is 4294967295? It's actually one less than 2^32. Now there's another important thing to keep in mind:

4GB = 4294967296 bytes

But why is it 1 greater than our result? Because our first byte is byte 0 while the last is byte 4294967295 for a total of 4294967296 bytes.

So now we're in a position where the smallest number that can exist in a 32-bit register is 0 and the largest number that can exist in a 32-bit register is 4294967295.

0 (binary)  - 1111111111111111111111111111111 (binary)
0 (decimal) - 4294967295 (decimal)
0 (hex)     - 0xFFFFFFFF (hex)

So there is 4GB of addressable space because anything above 4GB will have an address that is too big of a number to fit inside a 32-bit number and thus inside a 32-bit register.

I did all this stuff inside excel and seeing it helped me a lot.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top