Java Utililty Methods Integer Align

List of utility methods to do Integer Align

Description

The list of methods to do Integer Align are organized into topic(s).

Method

intalign(final int value, final int align)
align
return (value + align - 1) & ~(align - 1);
intalign(final int value, final int alignment)
Align a value to the next multiple up of an alignment number.
return (value + (alignment - 1)) & ~(alignment - 1);
intalign(final int value, final int pow2alignment)
Fast alignment operation with power of 2 alignment and value >=0 and value < Integer#MAX_VALUE .
In order to be fast is up to the caller to check arguments correctness.
return (value + (pow2alignment - 1)) & ~(pow2alignment - 1);
intalign(int addr, int align)
align
if ((addr % align) == 0) {
    return addr;
} else {
    return ((addr / align) + 1) * align;
Stringalign(int cur, int longest)
Returns a string with the number of spaces to align two strings.
String toret = "";
for (int i = cur; i < longest; i++) {
    toret = toret.concat(" ");
return toret;
Stringalign(int i)
align
String s = String.valueOf(i);
if (s.length() == 0) {
    return "00" + s;
if (s.length() == 1) {
    return "0" + s;
return s;
...
intalign(int min, int number, int max)
align
return Math.min(max, Math.max(min, number));
intalign(int pos, int align)
align
if ((pos % align) != 0)
    return pos + (align - (pos % align));
return pos;
intalign(int size)
Align |size| on BindingsHelper#ALIGNMENT .
return (size + ALIGNMENT - 1) & ~(ALIGNMENT - 1);
intalign(int size, int align)
align
assert isPowerOf2(align);
return (size + align - 1) & ~(align - 1);