Results 1 to 4 of 4
  1. #1
    scorp200 is offline Member
    Join Date
    Dec 2009
    Posts
    2
    Rep Power
    0

    Default bigger than long

    hey im working on new program that multiply all the numbers that lower than the input,
    here the code:
    PHP Code:
     import java.util.*;
       import TerminalIO.KeyboardReader;
        public class count
       {
           public static void main(String[]args)
          {
             KeyboardReader input = new KeyboardReader();
             int check=input.readInt("Enter number: ");
             long count=1;
             while (check>=1)
             {
                count*=check;
                check--;
             }
             System.out.println(count);		  
          
          }
       
       }
    when the input is around 30 the output is negative
    and when its 66+, its 0.
    is there some thing bigger than long?
    or there is other way?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    s there some thing bigger than long?

    BigInteger

    or there is other way?

    Stirling's approximation

  3. #3
    scorp200 is offline Member
    Join Date
    Dec 2009
    Posts
    2
    Rep Power
    0

    Default

    i figured it out
    thanks, big integer is really usefull
    Last edited by scorp200; 12-06-2009 at 07:07 AM.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

Similar Threads

  1. Help with a long sorting program.
    By leiferouis in forum New To Java
    Replies: 12
    Last Post: 02-04-2009, 04:46 AM
  2. Long Cannot Be Dereferenced?
    By caps_lock in forum New To Java
    Replies: 1
    Last Post: 01-18-2009, 01:49 AM
  3. Calculate sum of long integer!
    By Julingo in forum New To Java
    Replies: 2
    Last Post: 09-09-2008, 11:50 PM
  4. It takes very long time.....
    By iresha in forum Advanced Java
    Replies: 6
    Last Post: 05-11-2008, 02:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •