Calculate remainder with 2 numbers BigInteger

1

How to calculate the rest with "%" from two BigInteger numbers?

    
asked by anonymous 25.02.2015 / 18:44

1 answer

1

Just use the mod of class BigInteger .

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;

class Ideone {
    public static void main (String[] args) throws java.lang.Exception  {
        BigInteger bi1, bi2, bi3;
        bi1 = new BigInteger("-100");
        bi2 = new BigInteger("3");

        bi3 = bi1.mod(bi2);
        System.out.println(bi3);
    }
}

See running on ideone .

    
25.02.2015 / 18:49