Skip to content

Commit 5a878b4

Browse files
committed
Fix
1 parent 838fa44 commit 5a878b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/com/thealgorithms/conversions/IPConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public static String ipToBinary(String ip) {
3535
private static String octetToBinary(int octet) {
3636
char[] binary = {'0', '0', '0', '0', '0', '0', '0', '0'};
3737
for (int i = 7; i >= 0; i--) {
38-
if (octet % 2 == 1) {
38+
if ((octet & 1) == 1) {
3939
binary[i] = '1';
4040
}
41-
octet /= 2;
41+
octet >>>= 1;
4242
}
4343
return new String(binary);
4444
}

0 commit comments

Comments
 (0)