473,396 Members | 1,866 Online

# storing a number with more than 10 digits in a variable

237 100+
i am having a problem \
i am preparing for a programming contest
and some questions are coming to me with an input of numbers each number has more than 10 digits in it.
i know i can store them in a string
but i need to compute them
and there is no way to store them in a variable
i need some help because i have faced two problems with this error.

and wish me luck in the contest

hsn
Dec 1 '07 #1
4 21671
JosAH
11,448 Expert 8TB
There is the 'long' type; it can store numbers in the range [-2^63,2^63) and there
even is the BigInteger type.

kind regards,

Jos
Dec 1 '07 #2
sukatoa
539 512MB
i am having a problem \
i am preparing for a programming contest
and some questions are coming to me with an input of numbers each number has more than 10 digits in it.
i know i can store them in a string
but i need to compute them
and there is no way to store them in a variable
i need some help because i have faced two problems with this error.

and wish me luck in the contest

hsn
You mean, like this?

identifier variable = 15 digit number?

recall,

datatype---------max.value(Can handle)------byte.used in register
byte ----------------------- +-127 -------------------------------- 1
short ---------------------- +-32768 ---------------------------- 2
int ------------------------- +-2147483647 -------------------- 4
long ------------------------ +- 9 x 10^18 ---------------------- 8

float ---------------------- +-3.4 x 10^38 ---------------------- 4
double -------------------- +-1.7 x 10^308 -------------------- 8

It is safe to use datatype "double" in computing large numbers...
for example, when you multiply 15 digits "999999999999999" by itself,
"double" is capable for handling the value "9.999999998 x 10^14"....

which is too small compare to its maximum value...

Hopefully it helps,

Dec 1 '07 #3
JosAH
11,448 Expert 8TB
It is safe to use datatype "double" in computing large numbers...
for example, when you multiply 15 digits "999999999999999" by itself,
"double" is capable for handling the value "9.999999998 x 10^14"....

What every computer scientist should know about floating point arithmetic.

kind regards,

Jos
Dec 1 '07 #4
sukatoa
539 512MB

What every computer scientist should know about floating point arithmetic.

kind regards,

Jos

Ive already posted it in Forum JAVA