Java Bit Clean clearBits(long value, long bits)

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

Description

Clears the bits of a value.

License

Open Source License

Parameter

Parameter Description
value the value.
bits the bits to clear.

Return

the resulting number.

Declaration

public static long clearBits(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  ww.j a v a  2 s  .  co m
     * Clears the bits of a value.
     * @param value      the value.
     * @param bits      the bits to clear.
     * @return         the resulting number.
     */
    public static long clearBits(long value, long bits) {
        return value & ~bits;
    }

    /**
     * Clears the bits of a value.
     * @param value      the value.
     * @param bits      the bits to clear.
     * @return         the resulting number.
     */
    public static int clearBits(int value, int bits) {
        return value & ~bits;
    }
}

Related

  1. clearBit(int value, int bitIndex)
  2. clearBit(int value, int index)
  3. clearBit(long n, int i)
  4. clearBit33ofDTS(byte[] array, int offset)
  5. clearBits(int value, int bits)
  6. clearBitsAfterInLastWord(int lastWord, int lastSetBit)
  7. clearBitsUpToLS(int n, int i)