Skip to content

Instantly share code, notes, and snippets.

@Baekjoon
Created April 17, 2015 09:12
Show Gist options
  • Save Baekjoon/eea15ca2ea36ea99f325 to your computer and use it in GitHub Desktop.
Save Baekjoon/eea15ca2ea36ea99f325 to your computer and use it in GitHub Desktop.
java biginteger compare, equals
import java.util.*;
import java.math.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
BigInteger a = sc.nextBigInteger();
BigInteger b = sc.nextBigInteger();
int c = a.compareTo(b);
if (c < 0) {
System.out.println("<");
} else if (c == 0) {
System.out.println("==");
} else {
System.out.println(">");
}
System.out.println("compareTo = "+c);
boolean e = a.equals(b);
if (e) {
System.out.println("==");
} else {
System.out.println("!=");
}
System.out.println("equals = "+e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment