Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BigInteger +- operations?

Is it possible to do +- operations like this somehow?

BigInteger a = new BigInteger("1");
BigInteger b = new BigInteger("2");
BigInteger result;

a+=b;
//result = a.add(b);
like image 276
membersound Avatar asked Dec 06 '25 02:12

membersound


1 Answers

Unfortunately not. Operator overloading is not supported in the Java language. The syntax only works for the other numeric primitive wrappers via auto-boxing, which wouldn't make sense for BigInteger as there's no equivalent primitive.

like image 102
SimonC Avatar answered Dec 07 '25 17:12

SimonC