Java BigInteger.signum()
Syntax
BigInteger.signum() has the following syntax.
public int signum()
Example
In the following code shows how to use BigInteger.signum() method.
/*from w ww . ja v a2 s.c o m*/
import java.math.BigInteger;
public class Main {
public static void main(String[] args) {
BigInteger bi1 = new BigInteger("0");
BigInteger bi2 = new BigInteger("10");
BigInteger bi3 = new BigInteger("-10");
// assign signum results of bi1, bi2, bi3 to i1, i2, i3
int i1 = bi1.signum();
int i2 = bi2.signum();
int i3 = bi3.signum();
// print i1, i2, i3 values
System.out.println(i1);
System.out.println(i2);
System.out.println(i3);
}
}
The code above generates the following result.