File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
main/java/com/thealgorithms/bitmanipulation
test/java/com/thealgorithms/bitmanipulation Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .thealgorithms .bitmanipulation ;
2
+
3
+ /**
4
+ * Numbers Different Signs
5
+ * @author Bama Charan Chhandogi
6
+ */
7
+
8
+ public class NumbersDifferentSigns {
9
+
10
+ public static boolean differentSigns (int num1 , int num2 ) {
11
+ return (num1 ^ num2 ) < 0 ;
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ package com .thealgorithms .bitmanipulation ;
2
+
3
+ /**
4
+ * test Cases of Numbers Different Signs
5
+ * @author Bama Charan Chhandogi
6
+ */
7
+
8
+ import static org .junit .jupiter .api .Assertions .*;
9
+
10
+ import org .junit .jupiter .api .Test ;
11
+
12
+ class NumbersDifferentSignsTest {
13
+
14
+ @ Test
15
+ void testDifferentSignsPositiveNegative () {
16
+ assertTrue (NumbersDifferentSigns .differentSigns (2 , -1 ));
17
+ }
18
+
19
+ @ Test
20
+ void testDifferentSignsNegativePositive () {
21
+ assertTrue (NumbersDifferentSigns .differentSigns (-3 , 7 ));
22
+ }
23
+
24
+ @ Test
25
+ void testSameSignsPositive () {
26
+ assertFalse (NumbersDifferentSigns .differentSigns (10 , 20 ));
27
+ }
28
+
29
+ @ Test
30
+ void testSameSignsNegative () {
31
+ assertFalse (NumbersDifferentSigns .differentSigns (-5 , -8 ));
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments