Java Binary Convert to binaryString2Long(String binString)

Here you can find the source of binaryString2Long(String binString)

Description

binary String Long

License

Open Source License

Declaration

public static int binaryString2Long(String binString) 

Method Source Code

//package com.java2s;

public class Main {
    public static int binaryString2Long(String binString) {
        int value = 0;
        int count = 1;

        for (int i = binString.length(); i > 0; i--) {
            if (Integer.parseInt(binString.substring(i - 1, i)) == 1) {
                value = value + count;//ww  w.j  av  a2  s .  co m
            }
            count = count * 2;
        }
        return value;
    }
}

Related

  1. binaryString(byte aByte, boolean prefix)
  2. binaryString2ByteArr(String binary)
  3. binaryStringToBytes(String binaryString)
  4. binaryStringToFloat(String value)