dealing with large numbers


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: dealing with large numbers

  1. #1
    Join Date
    Jul 2004
    Posts
    10

    dealing with large numbers

    Hi,
    I'm supposed to calculate some rediculously large numbers (like 46^75). I know these numbers are definitely way beyond the capacity of doubles. Can anyone suggest a variable type to do that? Thanks.

  2. #2
    Join Date
    Jul 2004
    Posts
    83
    instead of double, use long. ex:
    long a=watever
    They say if you play a Microsoft Windows CD backwards it will play satanic messages. But thats nothing, if you play it forwards it installs Windows.

  3. #3
    Join Date
    May 2004
    Posts
    219
    That isn't quite long enough

    Code:
    BigDecimal d = new BigDecimal(Math.pow(46,75));
    Code:
    50914018510357733692393581562939574405608588594976882332374683237310907296616337
    624639423841109727047053358355569614346256384

  4. #4
    Join Date
    Jul 2004
    Posts
    10
    Drain,
    Thanks a bunch! Now another question is how do I raise this number to the power of 1/75? I know this sounds stupid, but my project requires such silly computations. so I need to do
    (46^75)^(1/75), which will be 46 again. I know that BigInteger has a function called pow() but it only takes int. Any idea?

  5. #5
    Join Date
    May 2004
    Posts
    219
    Well, n^(1/a) is equivalent to the a root of n. Unfortunately, BigInteger doesn't have a method for that either... I'm not sure how you would do that.

  6. #6
    Join Date
    Feb 2004
    Posts
    808
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center