Here you can find the source of mod(BigInteger v, BigInteger m)
Parameter | Description |
---|---|
v | a value |
m | a modulus |
Parameter | Description |
---|---|
ArithmeticException | when m = 0 |
public static BigInteger mod(BigInteger v, BigInteger m) throws ArithmeticException
//package com.java2s; //License from project: Open Source License import java.math.BigInteger; public class Main { /**/*from ww w. j av a2 s. c om*/ * Returns v (mod m).<br> * The value returned lies in range [ 0 .. |m| - 1 ].<br> * mod( x, m ) = mod( x, -m ).<br> * This method differs from {@link java.math.BigInteger#mod} in that it supports negative modulus.<br> * If m = 0 then ArithmeticException is thrown. * @param v a value * @param m a modulus * @return v (mod m) * @throws ArithmeticException when m = 0 */ public static BigInteger mod(BigInteger v, BigInteger m) throws ArithmeticException { return v.mod(m.abs()); } }