Positive and negative BigIntegers
Hi
How do you convert a negative BigInteger into a positive BigInteger? I know how to do it with in Integer:
if (y< 0)
{
y = -(y);
}
But how would you do the same type of operation with a BigInteger?
Many thanks, Ron
[354 byte] By [
cakea] at [2007-10-2 11:59:18]

> Hi
>
> abs() doesn't work for a BigInterger!
>
> Many thanks, Ron
Yes it does:
java.math.BigInteger neg = new java.math.BigInteger("-666");
java.math.BigInteger pos = neg.abs();
System.out.println("neg="+neg+"\npos="+pos);
http://java.sun.com/j2se/1.3/docs/api/java/math/BigInteger.html
> Ignore that, it does work, sorry!> > Thanks, again :)> > RonAlways better to find it out yourself!; )Good luck.