Java Bit Set setBit(int flag, int i)

Here you can find the source of setBit(int flag, int i)

Description

set Bit

License

Open Source License

Return

`flag' with bit `i' set to 1

Declaration

public static final int setBit(int flag, int i) 

Method Source Code

//package com.java2s;
/*//ww  w  .  j a v  a 2 s  .  co m
 * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

public class Main {
    /**
     * @return `flag' with bit `i' set to 1
     */
    public static final int setBit(int flag, int i) {
        return flag | pow2(i);
    }

    private static final int pow2(int n) {
        return 1 << n;
    }
}

Related

  1. setBit(int bitmask, int bit, boolean enabled)
  2. setBit(int bits, int index)
  3. setBit(int changeValue, int position, int value)
  4. setBit(int data, int bit, int value)
  5. setBit(int f, int i)
  6. setBit(int flags, int bit)
  7. setBit(int i, int bit, boolean enabled)
  8. setBit(int i, int bit, boolean state)
  9. setBit(int integer, int bit)