Answers for "conversion of decimal to binary in java"

2

Convert decimal number to binary in java without using array

public class DecimalToBinaryWithoutArray
{
   static void toBinary(int num)
   { 
      StringBuilder sb = new StringBuilder(); 
      int a = 0;
      while(num > 0)
      {
         sb.append(num % 2);
         a++;
         num = num / 2;
      }
      System.out.println(sb.reverse()); 
   }
   public static void main(String[] args) 
   {
      int number = 20; 
      toBinary(number);
   }
}
Posted by: Guest on February-18-2021
3

int to binary java

String binary = Integer.toBinaryString(num);
Posted by: Guest on May-09-2020

Code answers related to "conversion of decimal to binary in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language