We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fe28d02 commit 43314f5Copy full SHA for 43314f5
src/binary/compareSigns/IntSignsComparator.java
@@ -0,0 +1,20 @@
1
+package binary.compareSigns;
2
+
3
+import utils.InputReader;
4
5
+// x ^ y is negative if x and y have opposite signs
6
+public class IntSignsComparator {
7
+ public static void main(String[] args) {
8
+ System.out.print("Input a number: ");
9
+ int x = InputReader.readInt();
10
+ System.out.print("Input another number: ");
11
+ int y = InputReader.readInt();
12
13
+ if ((x ^ y) < 0) {
14
+ System.out.println("They have opposite signs");
15
+ }
16
+ else {
17
+ System.out.println("They have the same sign");
18
19
20
+}
0 commit comments