Working out address alignment
alignment, c++
Solution
An address A is n-aligned if A mod n is 0. So 0x12345671 and 0x12345673 are 1 aligned, and 0x12345672 is 2-aligned. 0x12345670 is, simultaneously, 1-aligned, 2-aligned, 4-aligned, 8-aligned, and 16-aligned. You only mention the highest power of two (as the lower powers are implied).
Problem
How do you work out the alignment of an address by just looking at it? On a 32bit system, an address of 0x12345670 means it's 16 byte aligned (because of the 0 on the end) right? So what about: 0x12345671 0x12345672 0x12345673 etc? Cheers, Jon