I need to printf a double, but i cant find a list fo the parameters anymore, anyone know the flag for double instead of single precision?
I need to printf a double, but i cant find a list fo the parameters anymore, anyone know the flag for double instead of single precision?
Try %f.
As opposed to scanf, printf has the same %f for both single and double, because single is translated to double before it's passed to printf.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
use google, for example to search msdn site:
http://www.google.com/search?hl=en&q...soft.com&meta=
http://msdn.microsoft.com/en-us/libr...w6(VS.80).aspx
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
I've always used %f for floats and %lf for doubles.
QuantumPete
"No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
"Have you tried turning it off and on again?" - The IT Crowd
That'll possibly work in some compilers, but %lf in the Gnu C library (glibc) is using %lf for extended precision double (long double), so you would get it wrong on a Linux machine for example. Assuming it does work, it still does the same thing for %lf and %f, since both float and double are converted to double before printf even gets a sniff of the format string or the floating point value itself.
I believe C99 makes %lf standard for long double.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
According to C99: f,F,e,E,g,G,a,A