[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

integer number too large

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
QLJ
Asked:
QLJ
2 Solutions
 
CEHJCommented:
You must use the methods of BigInteger for calcs
0
 
girionisCommented:
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
 
girionisCommented:
> DO I need to convert all of them to the same type?

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

Regards
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
CEHJCommented:
>>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
 
bvanderveenCommented:
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
 
objectsCommented:
> 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

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now