Java Bit Set setBits(long value, long bits)

Here you can find the source of setBits(long value, long bits)

Description

Sets the bits of a value.

License

Open Source License

Parameter

Parameter Description
value the value.
bits the bits to set.

Return

the resulting number.

Declaration

public static long setBits(long value, long bits) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009-2016 Black Rook Software
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
 ******************************************************************************/

public class Main {
    /**//from   w w w .j a va2 s  . c  om
     * Sets the bits of a value.
     * @param value      the value.
     * @param bits      the bits to set.
     * @return         the resulting number.
     */
    public static long setBits(long value, long bits) {
        return value | bits;
    }

    /**
     * Sets the bits of a value.
     * @param value      the value.
     * @param bits      the bits to set.
     * @return         the resulting number.
     */
    public static int setBits(int value, int bits) {
        return value | bits;
    }
}

Related

  1. setBitRange(final int val, final int start, final int len, final int newVal)
  2. setBits(byte in, byte data, int position, int fillBits)
  3. setBits(final byte value, final int bitMask, final boolean val)
  4. setBits(int lowBit, int numBits)
  5. setBits(int value, int bits)
  6. setBitsFromLong(byte[] dst, long dstoff, long l, int off, int len)
  7. setBitsInLong(long l, int n, int k, long v)
  8. setBitTo0(final long word, final int idx)
  9. setBitValue(byte aByte, int bitIndex, int bitValue)