BigInteger signum() in Java

signum(): This method is available in java.math.BigInteger class of Java.

Syntax:

int java.math.BigInteger.signum()

This method returns the signum function of this BigInteger.

Returns: -1, 0, or 1 as the value of this BigInteger is negative, zero, or positive.

For Example:

BigInteger bigInteger = new BigInteger("1234")

bigInteger.signum() = > It returns 1.

Approach

Java

import java.math.BigInteger;

public class BigIntegersignum {
    public static void main(String[] args) {

        BigInteger bigInteger = new BigInteger("1234");
        System.out.println(bigInteger.signum());

    }
}

Output:

1

No comments:

Post a Comment