Java examples for java.lang:int Binary
Converts a little endian boolean array representing bits into an Integer
//package com.java2s; public class Main { /**/* w w w . j ava 2 s.c om*/ * Converts a little endian boolean array representing bits into an {@link Integer} * * @param bits - little endian boolean array * @return appropriate {@link Integer} */ public static int bytesToInt(boolean[] bits) { int sum = 0; int multiplier = 1; for (boolean b : bits) { if (b) { sum += multiplier; } multiplier *= 2; } return sum; } }