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 07-23-2013, 09:54 PM   #1
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,965

Rep: Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622
Huge number calculations


Has any work been done that improves the java huge number work. I need to work with some really large computations but I also can't have any errors or rounding.

Thanks.
 
Old 07-24-2013, 12:42 AM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
Large data crunching in java ?
LOL

think CUDA

why java ?
i do a lot with multi GIG data sets and would never think of using java
c++, FORTRAN, Perl, or cuda yes but not java

Last edited by John VV; 07-24-2013 at 12:57 AM.
 
Old 07-24-2013, 01:05 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,782

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
Yes, why java? What about BigDecimal?
 
Old 07-24-2013, 02:59 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,965

Original Poster
Rep: Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622
I may have led you astray. I really need any method that would work in a modern x86-64 since that is my target device right now.

All I found was a biginteger set of java for this task that had exact results.

I never thought about using cuda or video card to do number calculations. I'll have to study on that since I know nothing about cuda.

There are some web pages that can do huge calculations like 30000 raised to 30000 for example but they fail at some point as the numbers get close to what I am working on. Or example maybe simple like 3 raised to 3 raised to 3.

Thanks for the ideas. I have not worked with python or ruby at all either so it will be an uphill battle.

Last edited by jefro; 07-24-2013 at 03:02 PM.
 
Old 07-24-2013, 04:06 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
CUDA is a pain in the bleep , so unless you can program in it ,it might not be a great choice

There is Perl and a mess of perl mods for math and calculations

Quote:
There are some web pages that can do huge calculations like 30000 raised to 30000 for example but they fail at some point as the numbers get close to what I am working on. Or example maybe simple like 3 raised to 3 raised to 3.
that sounds a bit like the 32 bit cut off or the long , double and int values set up in the code
 
Old 07-24-2013, 04:59 PM   #6
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Or you could install the genius package (and the needed libraries). Then use the GEL script to program your computation to whatever degree of precision you want. For example:
Code:
$ printf "FloatPrecision=1000;sum n=1 to 500 do 1/n\n" | genius
6 77421451437497033795232306235083075377047642888468868316076570503457478332206708245946938688923108952784535733...
Note that it is impossible to get an exact, non integer, result for a computation on a digital computer. You can find an interval containing such a result. See the mpfi library package for multiple precision floating point interval computation routines.
 
1 members found this post helpful.
Old 07-24-2013, 07:52 PM   #7
reza_zah1991
Member
 
Registered: Mar 2013
Location: Qom , Iran
Distribution: opensuse,lubuntu
Posts: 32

Rep: Reputation: Disabled
Thumbs up

you can do your other work with java & each time you need to calculate the huge Number,,use power of ShellScript from java(connect from java to OS consol),,
and save the huge number in the string,,
 
Old 07-24-2013, 08:14 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,965

Original Poster
Rep: Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622
Again thanks for the ideas and I appreciate any ideas. This is now simply a hobby sort of quest.

I had considered a purpose designed chip even but the end product would have to be an add on card for the task.

I have been looking at crypto tech on this also and did study up on cuda. It may be possible but as you say, a lot going on for a newbie to program.

"Note that it is impossible to get an exact, non integer, result for a computation on a digital computer"
This is my problem. I can't have any guesses and other built in cheats that have been wrongly added into the entire math portion of x86. It needs to be precise.

It is a true integer but in a very great length. I am only working with whole real numbers. At some point in the calculation, I need to end up with this huge number.

reza_zah1991, thanks for the idea, doing that over a network is what I am trying to avoid actually. Yes, a different system could do this.

Last edited by jefro; 07-24-2013 at 08:17 PM.
 
Old 07-24-2013, 10:07 PM   #9
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by PTrenholme View Post
Note that it is impossible to get an exact, non integer, result for a computation on a digital computer.
You can get exact results for a computation involving rational numbers. Obviously, you can't get exact results for irrational numbers, but that's independent of whether or not you are performing the computation on a computer, digital or otherwise.

Unless you are thinking of symbolic manipulation of real numbers? That can also be done on a digital computer.

Quote:
Originally Posted by jefro
It is a true integer but in a very great length. I am only working with whole real numbers.
So what is wrong with BigInteger? Is it too slow? Doesn't implement the functions you need?
 
Old 07-25-2013, 09:37 PM   #10
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Originally Posted by ntubski View Post
You can get exact results for a computation involving rational numbers. Obviously, you can't get exact results for irrational numbers, but that's independent of whether or not you are performing the computation on a computer, digital or otherwise.
O.K., I was being a little sloppy. What I was trying to say was that representation of real numbers in IEEE format on a digital computer is almost always inexact. That is, the set of points where the representation is exact has measure zero for most reasonable metrics. In fact, that set, for any finite precision, is (necessarily) finite.

It is also obvious that the set of integers that can be used by any (finite) digital computer is finite.

The size of those sets can be made quite large, but never infinite.
 
Old 07-26-2013, 02:32 PM   #11
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by ntubski View Post
You can get exact results for a computation involving rational numbers. Obviously, you can't get exact results for irrational numbers, but that's independent of whether or not you are performing the computation on a computer, digital or otherwise.
You can get an exact fractional representation of a rational number, but not necessarily the exact decimal notation. A fractional representation is merely a very simple case of algebraically representing a number, just like a floating-point is an exact representation of a particular number broken down into a mantissa and an exponent. Just to be facetious, I can compute 2*pi exactly: it's 2*pi. I just run into problems when I try to expand it into a finite decimal representation. Similarly, I can express pi as an algorithm of finite length.

The nice thing about rational numbers is that they're a commutative ring, and by definition they all have a fractional representation, so arithmetic doesn't cause the representation of the result to be more complicated than the operands. I believe numbers of the form [a+sqrt(b)]/[c+sqrt(d)] (for integers a-d) are also a commutative ring, so you could also perform exact arithmetic on them.

Kevin Barry

Last edited by ta0kira; 07-26-2013 at 02:46 PM.
 
Old 07-26-2013, 05:53 PM   #12
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by ta0kira View Post
You can get an exact fractional representation of a rational number, but not necessarily the exact decimal notation. A fractional representation is merely a very simple case of algebraically representing a number, just like a floating-point is an exact representation of a particular number broken down into a mantissa and an exponent.
...
Hah, the nipicker becomes the nitpickee A fair point, though.

I'm mainly concerned with clarifying that this isn't specific to (digital) computers.

Quote:
Originally Posted by PTrenholme
It is also obvious that the set of integers that can be used by any human (or (finite) digital computer) is finite.
Fixed that for you.
 
Old 07-29-2013, 08:43 PM   #13
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,965

Original Poster
Rep: Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622
Sorry I didn't get back to this.

Biginteger isn't bad and may be all that there is. I was looking for options. The cuda idea is one that I'll pursue maybe. If anyone has done this in python or perl I'd like their opinions.
 
Old 07-29-2013, 10:18 PM   #14
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,217

Rep: Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309Reputation: 5309
Python can handle 30000 to the power of 30000 just fine.

Code:
a = 30000 ** 30000
print a

Last edited by dugan; 07-30-2013 at 03:32 PM. Reason: Left out an asterisk
 
Old 07-30-2013, 02:59 PM   #15
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,965

Original Poster
Rep: Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622Reputation: 3622
a = 30000 * 30000

Should that be 30000 ** 30000 ?

Or maybe

math.pow(30000, 30000)

I guess I need to learn python and install it and try it.
 
  


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
IP to DNS converter that can handle a huge number of entries pkramerruiz Programming 1 05-06-2012 02:55 PM
[SOLVED] sort -n, huge number kaz2100 Programming 4 01-23-2011 06:12 AM
[SOLVED] Newbie - what to do about huge number attempted ssh logins cnmoore Linux - Security 25 09-16-2010 07:12 AM
powertop reporting a huge number of acpi interrupts gawhelan Linux - Laptop and Netbook 5 01-15-2009 02:12 AM
Problem with huge number of pthreads Berng Programming 7 12-17-2003 07:33 AM

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

All times are GMT -5. The time now is 07:52 AM.

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