Java Bits Convert to bits2Numeric(boolean[] in)

Here you can find the source of bits2Numeric(boolean[] in)

Description

Converts a vector of booleans to a numeric representation.

License

Open Source License

Parameter

Parameter Description
in a parameter

Return

numeric representation of flag

Declaration

public static int bits2Numeric(boolean[] in) 

Method Source Code

//package com.java2s;

public class Main {
    /**//w  w  w.  j  av a  2s.  co m
     * Converts a vector of booleans to a numeric representation.
     *
     * @param in
     * @return numeric representation of flag
     */
    public static int bits2Numeric(boolean[] in) {
        int numeric = 0;
        for (int i = 0; i < in.length; i++) {
            if (in[i])
                numeric += 1 << i;
        }
        return numeric;
    }
}

Related

  1. bitrv208(double[] a, int offa)
  2. bitrv208neg(double[] a, int offa)
  3. bitrv216neg(double[] a, int offa)
  4. bitrv2conj(int n, int[] ip, double[] a, int offa)
  5. bits2float(int i)
  6. bitsArrayToByte(byte[] bits)
  7. bitscanForward(long bitboard)
  8. bitsCleanup(int base, int[] bits)
  9. BitsNeeded(int n)