Answered by : super-stoat-n35omgy1k2dt
int n = 1000;
String s = Integer.toBinaryString(n);
Source : | Last Update : Mon, 08 Jun 20
Answered by : super-stoat-n35omgy1k2dt
public static String makeBinaryString(int n) { StringBuilder sb = new StringBuilder(); while (n > 0) { sb.append(n % 2); n /= 2; } sb.reverse(); return sb.toString();
}
Source : | Last Update : Wed, 03 Jun 20
Answered by : lonely-lark-mc835iuchiml
String binary = Integer.toBinaryString(num);
Source : | Last Update : Sat, 16 May 20
Answered by : stormy-swan-kwyqohapzv74
public class decToBin{ static void ab(int iput){ String output = ""; if(iput <= 0){ System.out.println("nope"); }else{ int a = iput; for(int i = 0; a > 0; i++){ a = Math.floorDiv(a, 2); output = (a % 2) + output; } } String b = ""; String c = ""; for (int index = 0; index < output.length(); index++) { c = output.charAt(index) + c; } System.out.println(c); } public static void main(String[] args) { System.out.println("test.."); ab(50); }
}
Source : | Last Update : Tue, 11 Oct 22
Answered by : you
public class DecimalToBinary { public static void main(String[] args) { int decimal = 25; String binary = ""; while (decimal > 0) { int remainder = decimal % 2; binary = remainder + binary; decimal = decimal / 2; } System.out.println("Binary representation: " + binary); }
}
Source : | Last Update : Tue, 19 Sep 23
Answered by : vishal-4vfs6l0xobcm
Integer.toBinaryString(int i)
Source : https://stackoverflow.com/questions/2406432/converting-an-int-to-a-binary-string-representation-in-java | Last Update : Thu, 25 Jun 20
Answered by : conrad-bhnke
String binaryString = Integer.toBinaryString(123);
Source : | Last Update : Wed, 02 Aug 23
Answered by : bissallah-ahmed-ekele-jr
Integer.toString(100,8) // prints 144 --octal representation
Integer.toString(100,2) // prints 1100100 --binary representation
Integer.toString(100,16) //prints 64 --Hex representation
Source : https://stackoverflow.com/questions/5263187/print-an-integer-in-binary-format-in-java | Last Update : Mon, 21 Dec 20