tags:

views:

24

answers:

2

hello

probably this is a real beginner question, but i cannot find an answer on the web. I have a Oracle db, with a table whose primary key is a NUMBER(16) and is filled with a sequence, whose max value is 999999999999999999999999999 .

what java type should i use to hold the sequence value ? long, biginteger or bigdecimal?

thank you in advance

+2  A: 

Firstly, please use scientific notation for large numbers. It took me a good chunk of time to work out that the number you posted was 1027.

If I understand your question correctly, we can probably leave the database out of it. Am I right in thinking that your question boils down to "I need to store positive integers up to 10^27. What is the smallest data type that will fit this?"

If so, a quick google shows that longs will definitely fit. BigInteger and BigDecimal will both also definitely contain your number, since they're arbitrary precision, but you don't need them, and they'll likely make your code more clunky (due to not being primitives). So unless you specifically need the Bignum functionality and methods, use long. (And I can't see any reason why you'd use a BigDecimal over BigInteger for inputs that are definitely whole numbers).

Andrzej Doyle
+4  A: 

Long should do as it has a maximum value of 2^63 - 1

Faisal Feroz
+1 Long should be good enuff.
Tingu