Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Stupidly Huge Numbers?

  1. #1
    Member
    Join Date
    Feb 2013
    Posts
    78
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Stupidly Huge Numbers?

    Hi all. So I was wondering, what if I want numbers larger than BigInteger? If I understand, I can use many variables or many BigIntegers as one number. I am wondering how I would do such a thing. I have searched around a bit but I will keep looking.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Stupidly Huge Numbers?

    BigInteger has arbitrary bitlengths, and in theory can represent any integer. In practice, you'll run out of physical memory first or the OS/Java runtime will limit how much memory you have.

    For a 1GB BigInteger, you can represent stupidly large numbers up to 2^4294967296. This is a 1,292,913,986 digit number.

    This is significantly larger than the largest known prime as of Jan 15, 2013.

    The only solution is to increase how much memory Java is allowed to use, or increase how much physical memory you have (or use virtual paged memory, though this is extremely slow).

  3. #3
    Member
    Join Date
    Feb 2013
    Posts
    78
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Stupidly Huge Numbers?

    is there a way to tell how much memory the variable is taking?

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Stupidly Huge Numbers?

    BigInteger.bitLength()

Similar Threads

  1. HUGE PROBLEM - PLEASE HELP! ArrayList issues
    By AustinStanley in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 25th, 2013, 07:06 AM
  2. Help simplifying huge nested if statement?
    By racecar333 in forum Loops & Control Statements
    Replies: 6
    Last Post: November 1st, 2011, 01:03 AM
  3. Replies: 1
    Last Post: April 7th, 2011, 01:32 PM
  4. Streaming Raw Data to a Client - huge message loss
    By MarkusTandy in forum Java Networking
    Replies: 0
    Last Post: February 19th, 2011, 07:41 PM