Java BigInteger

  • + 0 comments

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger;

    public class BigIntegerJava {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String a = reader.readLine();
        String b = reader.readLine();
    
        BigInteger num1 = new BigInteger(a);
        BigInteger num2 = new BigInteger(b);
    
        //addition
        //abstract negatives
        BigInteger addition = num1.abs().add(num2.abs());
        System.out.println(addition);
    
        //multiplication
        //abstract negatives
        BigInteger product = num1.abs().multiply(num2.abs());
        System.out.println(product);
    }
    

    }