long « Number « Java Data Type Q&A

1. What to do when you need to store a (very) large number?    stackoverflow.com

Hey, I am trying to do a project euler problem but it involves adding the digits of a very large number. (100!) Using java, int and long are too small. Thanks for ...

2. Java's L number (long) specification question    stackoverflow.com

It appears that when you type in a number in java, the compiler automatically reads it as an integer, which is why when you type in (long) 6000000000 (not in Integer's ...

3. How can I check if multiplying two numbers in Java will cause an overflow?    stackoverflow.com

I want to handle the special case where multiplying two numbers together causes an overflow. The code looks something like this:

int a = 20;
long b = 30;

// if a or b ...

4. Java: random long number in 0 <= x < n range    stackoverflow.com

Random class has a method to generate random int in a given range. For example:

Random r = new Random(); 
int x = r.nextInt(100);
This would generate an int number more or equal ...

5. java long number calculate problem    stackoverflow.com


public class Main{
    public static void main(String[] a){
        long t=24*1000*3600;

6. Finding the prime factor of a Long number using Java    stackoverflow.com

public class prime
   public static void main(String[] args)
     long thing = 600851475143L;
     for(long i = 300425737571L ; ...

7. Java - Can't make ProjectEuler 3 Work for a very big number (600851475143)    stackoverflow.com

It turns out there is (probably) "nothing wrong" with the code itself, it is just inefficient. If my math is correct, If I leave it running ...

8. Random number with uniform distribution over a long period    stackoverflow.com

I would like to generate (quality) random numbers in my Java EE application over a long period of time (dozens of numbers per day). It should keep the uniform distribution even ...

9. How to remove zero in front of string and cast in number in java    stackoverflow.com

I have string 0000001.45 and I want to remove zero in front of the string and convert string to long. Is it possible to cast without loops. Have java some function ...

10. Number is too long to be passed to Random() ?    stackoverflow.com

I'm trying to do

Random generator = new Random(1309233053284);
Random being java.util.Random It says the number is too long, but why can System.currentTimeMillis() be passed to the constructor? It returns even bigger numbers. 1309233053284 are ...

11. If you convert a Java Long to another base, how do you get it back from the String it was converted to?    stackoverflow.com

After you convert a number to a different base:

String thirteenAsBase36 = Long.toString(13, 36);
How do you convert the String back to a normal base 10 number?
Long thirteenAsBase10 = ?

12. Writing to Excel from Java takes long time for large number of records    stackoverflow.com

I am using Jxl API to write to Excel,to export large number of records to excel. For my configuration number of records are around 40000. and for before writing these records ...

14. merge two long numbers into one long number    bytes.com

i am implementing blowfish algorithm.. i have a long number or a 64 bit no. say X i have to divide this 64 bit block into two 32 bit blocks say ...

15. Showing Long Numbers    coderanch.com

16. convert long or String to Number    coderanch.com

17. Problem in taking difference between two long number.    coderanch.com

Hi Friends, I have to Upload a file where we will have two 14 digit number called fromNumber and toNumber , so i assigned those two numbers to long datatype. when i upload a large number of file say(5 lakhs records), at that time, to some of the records are coming with minus number (this happends only for some number) Could ...

18. Storing numbers as variable type long    coderanch.com

19. A number outside range of long ?    coderanch.com

20. Programming with objects to turn a long number into strings.    java-forums.org

Programming with objects to turn a long number into strings. Hello again everyone, so I have been working on this program for a couple of days, and I have screwed it up badly, re-fixed it, and screwed it all up again many many times. Here are the parameters for the assignment: I must use objects in java to take ...

21. How to deal with very long numbers    forums.oracle.com

22. Long number to 2 digits    forums.oracle.com

Hi All I have a problem formatting a number in Java and cannot find a solution anywhere, would grealty appreciate any sugestions. I have two long numbers I am using as minutes:seconds but these numbers are not displaying correctly. e.g. 0:334234 where I would like to round to 2 digits only. long diff = this.endTime.getTime() - getStartTime().getTime(); long minutes = diff ...

23. put number 10e12 into "long"    forums.oracle.com

24. Creating long number issue    forums.oracle.com

26. Number of digits of a Long value    forums.oracle.com

27. Prime Number Checker--working, but won't take numbers long enough.    forums.oracle.com

I'm less concerned about the computational speed; I'd rather get the code elegant and THEN fiddle with it. I already know that 1000000000001 and 10000000000003 are twin primes; why when I start the value of "number" at 1000000000001 do I still get that loop? Theoretically speaking, it should stop and print the success message on the first iteration, but it does ...

28. Handling and holding Long Long Number    forums.oracle.com

29. how to convert number 10 to a long value ?    forums.oracle.com

Hello What is the corresponding long value for number 10 ? I am trying to compare timestamp time1: long value of 09:10:00 is 1206105000929 time2: long value of 09:08:20 is 1206104900929 I need to get the difference between time1 and time2 and check if that difference is less than 10, but I do not know the long value for 10 b/c ...

30. Applying modulo % operator on Long number    forums.oracle.com