Function isAligned [src]

Given an address and an alignment, return true if the address is a multiple of the alignment The alignment must be a power of 2 and greater than 0.

Prototype

pub fn isAligned(addr: usize, alignment: usize) bool

Parameters

addr: usizealignment: usize

Example

test isAligned { try testing.expect(isAligned(0, 4)); try testing.expect(isAligned(1, 1)); try testing.expect(isAligned(2, 1)); try testing.expect(isAligned(2, 2)); try testing.expect(!isAligned(2, 4)); try testing.expect(isAligned(3, 1)); try testing.expect(!isAligned(3, 2)); try testing.expect(!isAligned(3, 4)); try testing.expect(isAligned(4, 4)); try testing.expect(isAligned(4, 2)); try testing.expect(isAligned(4, 1)); try testing.expect(!isAligned(4, 8)); try testing.expect(!isAligned(4, 16)); }

Source

pub fn isAligned(addr: usize, alignment: usize) bool { return isAlignedGeneric(u64, addr, alignment); }