Revert "BAEL-4134"
This commit is contained in:
committed by
GitHub
parent
4a35b97bad
commit
7ab2f437ee
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.integerToBinary;
|
||||
|
||||
public class IntegerToBinary {
|
||||
public static String convertIntegerToBinary(int n) {
|
||||
if(n == 0) {
|
||||
return "0";
|
||||
}
|
||||
StringBuilder binaryNumber = new StringBuilder();
|
||||
while (n > 0) {
|
||||
int remainder = n % 2;
|
||||
binaryNumber.append(remainder);
|
||||
n /= 2;
|
||||
}
|
||||
binaryNumber = binaryNumber.reverse();
|
||||
return binaryNumber.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user