Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
July 16, 2004 printf does not support type real | ||||
---|---|---|---|---|
| ||||
The subject says it all. I have to cast to a double to print values of this type. Sean |
July 16, 2004 Re: printf does not support type real | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | 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
|
July 16, 2004 Re: printf does not support type real | ||||
---|---|---|---|---|
| ||||
Posted in reply to Cabal | 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. |
July 16, 2004 Re: printf does not support type real | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | "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. |
July 16, 2004 Re: printf does not support type real | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | 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 |
July 16, 2004 Re: printf does not support type real | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | 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? ;-)
|
July 17, 2004 Re: printf does not support type real | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | "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. |
July 17, 2004 Re: printf does not support type real | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | > Haven't you noticed by now that everybody has
> issues? ;-)
some more than others ;)
|
July 17, 2004 Re: printf does not support type real | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | 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/ |
Copyright © 1999-2021 by the D Language Foundation