Solved

integer number too large

Posted on 2004-08-26
6
393 Views
Last Modified: 2009-12-16
Hi,
I tried to do this: private static long prime=5095271039;
why is this so? I thgt long gives value to 64bits? This value is obtained from BigInteger.

i want to work with the numbers arithmetically, some int, some BigInteger. DO I need to convert all of them to the same type?
0
Comment
Question by:QLJ
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 11904294
You must use the methods of BigInteger for calcs
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 20 total points
ID: 11904301
If you have an int you should declare it as an int, otherwise declar its type. Try this:


private static long prime=5095271039L;


Regards
0
 
LVL 35

Expert Comment

by:girionis
ID: 11904310
> DO I need to convert all of them to the same type?

I am afraid you will be needed to do, yes.

Regards
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 86

Expert Comment

by:CEHJ
ID: 11904321
>>some BigInteger

If you have some that are BigInteger, then presumably there's a good reason (they're big), so if they *are* too big for long or int, then you must use BigInteger
0
 
LVL 7

Expert Comment

by:bvanderveen
ID: 11905830
It is best to make all datatypes the largest datatype needed.  Kind of a pain, but it avoid a lot of problems that can result from the JVM overflowing calcluations, then converting the result to the larger type.  This doesn't throw any warnings or exceptions, you just get screwy results.
0
 
LVL 92

Accepted Solution

by:
objects earned 30 total points
ID: 11907425
> DO I need to convert all of them to the same type?

Not at all, you just need to ensure that you cast appropriately.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now