LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-17-2006, 10:45 AM   #1
MRMadhav
Member
 
Registered: Nov 2005
Location: Mauritius
Distribution: PCQLinux, SUSE Linux,Fedora Core 5, Fedora Core 6, Knoppix Live, Kubuntu Edgy, PCLinuxOS
Posts: 167

Rep: Reputation: 30
Exclamation 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!
 
Old 01-17-2006, 01:20 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

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

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
 
Old 01-18-2006, 02:03 PM   #3
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
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));
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
printf unsigned long long int? blackzone Programming 9 03-04-2008 12:41 PM
Even numbers paraiso Linux - Newbie 4 05-15-2005 03:31 PM
Adding numbers, break on non-numbers... Cruger Programming 1 03-22-2004 09:18 AM
on JAVA: finding perfect numbers randomx Programming 2 10-05-2003 12:36 PM
floating point numbers in java spyghost Programming 8 09-06-2003 06:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration