0

# How can I store a big number? for example I want to store the 100000000 ! and I want it in my calculation

11th Apr 2017, 12:48 PM
SaraBolouri
11th Apr 2017, 1:11 PM
Meharban Singh
+ 7
Use BigInteger. Here's a small tutorial. https://code.sololearn.com/WS60ll19CFej/?ref=app
11th Apr 2017, 12:53 PM
Krishna Teja Yeluripati
+ 6
Keep in mind that if you use strings each digit in number will take 1 byte of memory. So if you got a number with 1000000000 digits you should find a 1 gb of RAM to store it.
11th Apr 2017, 1:00 PM
Jeth
+ 5
use long integer or reference data type..
11th Apr 2017, 1:37 PM
Saumya
+ 5
use datatype of long, you can store that number. Else, you can use string.
11th Apr 2017, 2:21 PM
Wen Qin
+ 4
Anytime bro, @SaraBolouri
11th Apr 2017, 3:25 PM
Meharban Singh
+ 4
use the data type "long" if the number is too big for an int. max number for long is like 9.4 quintillion, so if the number is bigger than that, use the BigInteger class
11th Apr 2017, 4:06 PM
Edward
+ 2
@Meharban Singh tnx a lot ... your code is very good for me
11th Apr 2017, 1:23 PM
SaraBolouri
+ 1
Dislike? Am I wrong? If yes I would love to hear where :)
11th Apr 2017, 12:57 PM
Dextozz
+ 1
@Jeth Never thought of that, thanks for teaching me something new :o
11th Apr 2017, 1:04 PM
Dextozz
+ 1
@Jeth l mean,not digits...my number is 1000000000,not the number of digits....but tax for teaching
11th Apr 2017, 1:11 PM
SaraBolouri
0
Store it as a string, I had the similar task where I had to add two numbers that were out of bonds of int and long. The way I did it is that I stored the number as a string, and added up each digits of the numbers indvidualy, kind of like kids do it in elementary school 12345 + 05678 ------------- 18023 Edit: @Krishna 's way works, but it still has a limited range of numbers it accepts where as this way doesn't. Keep in my by doing it this way you can't really do complex stuff efficiently.
11th Apr 2017, 12:53 PM
Dextozz
- 1
use data type "long"
11th Apr 2017, 2:48 PM
Himani Sharma