472,145 Members | 1,510 Online

# Format specifier for double and lond double in C

I am making a project on the basis of numbers........here i need that i print a bigger number whose lenght is more than 300 digits....... while i am doing it in C than i am getting a problem my all digit convert in base of "e" and i get the number in this format 1.222222222222222222222222222222222200000000000000 00000000000000000000000e+127
but i need that my number will displayed as 1.222222222222222222222222222222222222222222222222 22222222222222222222222222222222222222222222222222 22222222222222222222222222222222222222222222222222 22222222222222222222222222222222222222222222222222 22222222222222222222222222222222222222222222222222 22222222222222222222222222222222222222222222222222 22222222222222222222222222222222222222222222222222 22222222222222222222222222222222222222222222222222 2222222222222222222222222222222222222222222222222
means whatever user enter its not matter but all digits must be print as it is..... may be any of lenght....... now how can i do this.....
i heard that ranhge of double is 10^+308 and long double is 10^+4092
but i dont know the format specifier of it.... and will they print the whole number accoring to their range........ plase help..........
Nov 3 '09 #1
3 5354
donbock
2,425 Expert 2GB
The C Standard Library does not support formatted I/O of 300-digit numbers. You will have to write your own functions to do this.
Nov 3 '09 #2
Banfa
9,065 Expert Mod 8TB
And you will not be able to use any basic floating point type such as float, double or long double because they may have the range to store the numbers you are interested in but they do not have the precision.
Nov 3 '09 #3
Ectara
24
If you were to do so, you could start by outputting the number digit by digit, starting with the most significant in a loop. Keep in mind, floating point inaccuracies will occur. IIRC, float can accurately store 6 digits, and double accurately stores 15 digits, mantissa included. Anything outside of that, could be anything.
Nov 3 '09 #4