Java Integer Create toInt(boolean[] bits)

Here you can find the source of toInt(boolean[] bits)

Description

to Int

License

Apache License

Declaration

private static int toInt(boolean[] bits) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static int toInt(boolean[] bits) {
        int value = 0;
        for (int i = 0; i < bits.length; i++) {
            boolean isSet = bits[i];
            if (isSet) {
                value += 1 << bits.length - i - 1;
            }// w  ww  .  jav  a 2s.  c  o m
        }

        return value;
    }
}

Related

  1. toInt(boolean flag)
  2. toInt(boolean value)
  3. toInt(byte b)
  4. toInt(byte b1, byte b2, byte b3, byte b4)
  5. toInt(byte byte0, byte byte1, byte byte2, byte byte3)
  6. toInt(byte byte3, byte byte2, byte byte1, byte byte0)