Horje
Convert Octal to Binary in java Code Example
Convert Octal to Binary in java
class Main {
  public static void main(String[] args) {
    int octal = 67;
    long binary = convertOctalToBinary(octal);
    System.out.println(octal + " in octal = " + binary + " in binary");
  }

  public static long convertOctalToBinary(int octalNumber) {
    int decimalNumber = 0, i = 0;
    long binaryNumber = 0;

    while (octalNumber != 0) {
      decimalNumber += (octalNumber % 10) * Math.pow(8, i);
      ++i;
      octalNumber /= 10;
    }

    i = 1;

    while (decimalNumber != 0) {
      binaryNumber += (decimalNumber % 2) * i;
      decimalNumber /= 2;
      i *= 10;
    }

    return binaryNumber;
  }
}




Java

Related
adding new field in existing kibana index using spark java Code Example adding new field in existing kibana index using spark java Code Example
how to show the hex detail of a file in java Code Example how to show the hex detail of a file in java Code Example
Spring security avec spring version 2.5.6 Code Example Spring security avec spring version 2.5.6 Code Example
how to put string in char array in java tutorialspoint Code Example how to put string in char array in java tutorialspoint Code Example
use scanner class in global scope java Code Example use scanner class in global scope java Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7