Update BinaryToOctal.java

added logic to convert binary to octal
This commit is contained in:
Eric Ruggieri
2017-05-24 13:46:54 -04:00
committed by GitHub
parent 4e14531e07
commit 10889f4993

View File

@ -29,7 +29,15 @@ public class BinaryToOctal {
* @return The octal number
*/
public static int convertBinaryToOctal(int b) {
int o = 0, r=0, j =1 ;
while(b!=0)
{
r = b % 10;
o = o + r * j;
j = j * 2;
b = b / 10;
}
return o;
}
}