Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
decToBin
//decToBin //'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_45 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { //isBinary int dec = 156; int temp = 0; int decBin = dec%2; String ans = ""+decBin; while(dec>1) { dec = dec/2; // System.out.println("dec: "+dec); decBin = dec%2; // System.out.println("decBin: "+decBin); ans = ""+decBin+ans; } System.out.println(ans); } }
run
|
edit
|
history
|
help
0
Display Page (Pagination)
2b
Odd
Remove punctuation except numbers, commas and spaces
Java
jb7.0 extends.override
Pattern1
rextester.java1
Three In A Row Solver
pk3