www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - printf does not support type real

reply Sean Kelly <sean f4.ca> writes:
The subject says it all.  I have to cast to a double to print values of this
type.


Sean
Jul 16 2004
next sibling parent reply Cabal <cabalN05P4M myrealbox.com> writes:
I could be wrong but I believe the printf used in D is the original C
function which only supports doubles in its original form. I seem to
remember seeing the use of a %lf format specifier on one platform or
another to indicate a long double (D real). You might try that to see if it
works - your mileage may vary, I don't believe it is a standard.

Sean Kelly wrote:

 The subject says it all.  I have to cast to a double to print values of
 this type.
 
 
 Sean
Jul 16 2004
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Cabal wrote:

 I could be wrong but I believe the printf used in D is the original C
 function which only supports doubles in its original form. I seem to
 remember seeing the use of a %lf format specifier on one platform or
 another to indicate a long double (D real).
FWIS, it's %Lf (uppercase L).
 You might try that to see if it
 works - your mileage may vary, I don't believe it is a standard.
Or even use writef now we have it.
 The subject says it all.
No it doesn't. It doesn't supply a code sample. Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit.
Jul 16 2004
next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"It doesn't supply a code sample."

semantics, semantics :P  if you can't figure out the problem from the title,
you've got issues.
Jul 16 2004
parent reply John Reimer <brk_6502 NO_SPA_M.yahoo.com> writes:
Jarrett Billingsley wrote:

 "It doesn't supply a code sample."
 
 semantics, semantics :P  if you can't figure out the problem from the
 title, you've got issues.
Why even bring this up? Haven't you noticed by now that everybody has issues? ;-)
Jul 16 2004
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
 Haven't you noticed by now that everybody has
 issues? ;-)
some more than others ;)
Jul 17 2004
prev sibling parent reply Sean Kelly <sean f4.ca> writes:
In article <cd936h$e9e$1 digitaldaemon.com>, Stewart Gordon says...
Cabal wrote:

 You might try that to see if it
 works - your mileage may vary, I don't believe it is a standard.
Or even use writef now we have it.
Oops. I had thought that printf now silently called writef behind the scenes. My mistake.
 The subject says it all.
No it doesn't. It doesn't supply a code sample.
In this case one shouldn't be necessary, but just to be pedantic: real x = 1.0; printf( "%f", x ); // prints garbage ie. I had thought that printf had been re-implemented by Walter and no longer required the size modifiers. Sean
Jul 16 2004
parent "Walter" <newshound digitalmars.com> writes:
"Sean Kelly" <sean f4.ca> wrote in message
news:cd973f$fvg$1 digitaldaemon.com...
 real x = 1.0;
 printf( "%f", x ); // prints garbage
Use %Lf for real's. printf is a C function, and D reals correspond to C long doubles.
Jul 16 2004
prev sibling parent J C Calvarese <jcc7 cox.net> writes:
Sean Kelly wrote:
 The subject says it all.  I have to cast to a double to print values of this
 type.
 
 
 Sean
This page might be helpful to you: http://www.prowiki.org/wiki4d/wiki.cgi?HowTo/printf It has a list of format specifiers corresponding to particular D types. If you find a mistake, you can even edit the page to fix it. With the advent of writef, I'll going to look at phasing out my calls to printf: http://www.digitalmars.com/d/phobos.html#stdio I think if I'm using writef, I won't run into random garbage or access violations from using the wrong specifier. (Actually errors messages are much more helpful.) -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Jul 17 2004