469,330 Members | 1,310 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

Format specifier for double and lond double in C

amarniit
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 5209
donbock
2,422 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,064 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

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

18 posts views Thread by Money | last post: by
1 post views Thread by dis_is_eagle | last post: by
2 posts views Thread by =?Utf-8?B?Um9ubmllIFNtaXRo?= | last post: by
1 post views Thread by raghunadhs | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.