Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 565
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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