# Thread: Big (and small) numbers...

1. ## Big (and small) numbers...

I have quite a few questions regarding variables in C, and their supported sizes. Firstly, I need to be able to hold a number (as large as) 9999999999 in a variable. I'm not sure which type to use (I've been told float or double can do the job)... Which would any of you recommend for this?

Also, I would like to have support for significant digits after a decimal point of up to 1 million. I'm not sure how far a double or long double supports in the negative region, but I would obviously need a range (at least) like this: 10^1000000 to 10^-1000000. Is this possible, and if, with what variable type?

Lastly, I am curious to know why when I use a float or a double (especially), when I use printf to print the variable, no matter how long (after the decimal) I declare it, it will only show 6 significant digits (Including numbers before the decimal). For instance, if I declare something to be 1.2345678, when using printf() to print the variable, I only get 1.23456. Similarly, if I declare a variable to be .12345678, I only get .123456. Do I need to declare the number of spaces after the decimal point to get this to work? (i.e.
Code:
`printf("%.10f\n", var);`
Any responses would be GREATLY appreciated!

2. 1) long long int (if your compiler supports it).
2) You'll have to write your own. Nothing will give you that precision, especially since floating point numbers in C are not precise.
3) When you write your own data type for your huge floating point numbers, you can go ahead and write your own input and output functions for it as well.

Quzah.

3. Just out of curiousity, why do you need that kind of percision?

4. ## precision necessary because....

I'm finding the first ten digit prime in consecutive digits. I want to make sure my number is exact because the function i wrote in e limits the amount of sig. digits in the loop.

if i calculate to 1000000 sig. digits, i dont' need to worry about the first 100000-200000 being inaccurate.

5. You might want to google on existing high-performance libraries. I've heard a great deal of "GMP" and "Miracl". Not sure if they are pure C though...