MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / calculateBinary

Method calculateBinary

Programs/Decimal_to_Binary.java:22–41  ·  view source on GitHub ↗
(int n,int positions)

Source from the content-addressed store, hash-verified

20 }
21
22 static void calculateBinary(int n,int positions){
23// int count = 0;
24// while(n>0){
25// n = n/2;
26// count ++;
27// }
28 int length = positions;
29
30 int[] Binary = new int[length];
31 int i =0;
32 while (n>0){
33 Binary[i] = n%2;
34 n = n/2;
35 i++;
36
37 }
38 for(int j= Binary.length-1; j>=0; j--){
39 System.out.print(Binary[j]);
40 }
41 }
42
43
44}

Callers 1

mainMethod · 0.95

Calls 1

printMethod · 0.80

Tested by

no test coverage detected