Here you can find the source of clearBit(int value, int bit)
Parameter | Description |
---|---|
value | The value in which the bit is to be cleared. |
bit | The bit to clear. |
public static int clearBit(int value, int bit)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w ww . j a v a 2 s. c o m*/ * Clear the bit within the int. * @param value The value in which the bit is to be cleared. * @param bit The bit to clear. * @return The value with the bit cleared. */ public static int clearBit(int value, int bit) { assert bit >= 0 && bit < 16; return value & ~bitMask(bit); } /** * Clear the bit within the byte. * @param value The value in which the bit is to be cleared. * @param bit The bit to clear. * @return The value with the bit cleared. */ public static byte clearBit(byte value, int bit) { assert bit >= 0 && bit < 16; return (byte) (value & ~bitMask(bit)); } /** * Calculate a bitmask of the bit. * @param bit The bit to be used to calculate the bitmask. * @return The value of the bitmask. */ public static int bitMask(int bit) { assert bit >= 0 && bit < 16; return 1 << bit; } }