LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Very Long Numbers In JAVA (https://www.linuxquestions.org/questions/programming-9/very-long-numbers-in-java-404482/)

MRMadhav 01-17-2006 10:45 AM

Very Long Numbers In JAVA
 
Hi,
I wanted to do some calculations in java with very long numbers, eg 112422220101123456789101000000223000,
My calculations are to get a remainder when dividing by 97 and to get the value of the division but not in exponential form. Can someone please help!

acid_kewpie 01-17-2006 01:20 PM

i don't understand your question, are you saying you need to find a number that is not divisible by 97?? :confused:

if you're having issues due to the size of the number with java, you may want to check the BigInteger class to support longer numbers more precisely. http://java.sun.com/j2se/1.5.0/docs/...igInteger.html

xhi 01-18-2006 02:03 PM

Yes big int works pretty slick..
here is a little snip..
Code:

BigInteger a = new BigInteger("112422220101123456789101000000223000");
BigInteger b = new BigInteger("97");
System.out.println(a.divide(b));
System.out.println(a.mod(b));



All times are GMT -5. The time now is 03:48 AM.