Java Integer Align align(int value, int alignment)

Here you can find the source of align(int value, int alignment)

Description

Returns the given (address) value, adjusted to have the given alignment.

License

Open Source License

Parameter

Parameter Description
value The address value
alignment The desired alignment

Return

The aligned address value

Declaration

public static int align(int value, int alignment) 

Method Source Code

//package com.java2s;
/*/* ww w .j  a va  2s .  c o m*/
 * Copyright (C) 2010-2014 - Andreas Maier 
 * CONRAD is developed as an Open Source project under the GNU General Public License (GPL).
 */

public class Main {
    /**
     * Returns the given (address) value, adjusted to have
     * the given alignment. In newer versions of JCuda, this
     * function is also available as JCudaDriver#align
     * 
     * @param value The address value
     * @param alignment The desired alignment
     * @return The aligned address value
     */
    public static int align(int value, int alignment) {
        return (((value) + (alignment) - 1) & ~((alignment) - 1));
    }
}

Related

  1. align(int pos, int align)
  2. align(int size)
  3. align(int size, int align)
  4. align(int size, int alignment)
  5. align(int size, int space, int weight)