diff --git a/src/main/java/com/thealgorithms/bitmanipulation/IsEven.java b/src/main/java/com/thealgorithms/bitmanipulation/IsEven.java new file mode 100644 index 00000000..c9129e47 --- /dev/null +++ b/src/main/java/com/thealgorithms/bitmanipulation/IsEven.java @@ -0,0 +1,12 @@ +package com.thealgorithms.bitmanipulation; + +/** + * Converts any Octal Number to a Binary Number + * @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi) + */ + +public class IsEven { + public static boolean isEven(int number) { + return (number & 1) == 0; + } +} \ No newline at end of file diff --git a/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java b/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java new file mode 100644 index 00000000..2e33539f --- /dev/null +++ b/src/test/java/com/thealgorithms/bitmanipulation/IsEvenTest.java @@ -0,0 +1,14 @@ +package com.thealgorithms.bitmanipulation; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class IsEvenTest { + @Test + void testIsEven() { + assertEquals(true, IsEven.isEven(2)); + assertEquals(true, IsEven.isEven(-12)); + assertEquals(false, IsEven.isEven(21)); + } +}