Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
January 25, 2002 D floating point | ||||
---|---|---|---|---|
| ||||
I am experimenting with this. I can do extended x = 1.; printf("%lf\n",(double)x); It needs the cast to get the correct answer. I was trying to do sprintf() to put it into a buffer, but sprintf would not compile. John |
January 25, 2002 Re: D floating point | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Fletcher | John Fletcher wrote:
> extended x = 1.;
> printf("%lf\n",(double)x);
>
> It needs the cast to get the correct answer.
My guess is that, since printf is currently coming from a C
library, its floating point support is going to match that
of the C implementation.
A reading of the Digital Mars C library docs suggest
you might try a capital L in the format spec:
printf( "%Lf\n", x );
...but that's just a guess on my part.
-Russell B
|
January 25, 2002 Re: D floating point | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russell Borogove | Yes, you need the Lf for "long double", which matches D's "extended". -Walter Why doesn't sprintf work for you? I use it! "Russell Borogove" <kaleja@estarcion.com> wrote in message news:3C51A3B4.5030602@estarcion.com... > John Fletcher wrote: > > > extended x = 1.; > > printf("%lf\n",(double)x); > > > > It needs the cast to get the correct answer. > > > My guess is that, since printf is currently coming from a C library, its floating point support is going to match that of the C implementation. > > A reading of the Digital Mars C library docs suggest > you might try a capital L in the format spec: > > printf( "%Lf\n", x ); > > ...but that's just a guess on my part. > > -Russell B > > > |
January 28, 2002 Re: D floating point | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote: > Yes, you need the Lf for "long double", which matches D's "extended". -Walter Thank you. > > > Why doesn't sprintf work for you? I use it! I don't know, I couldn't get it to compile, so I dug in the phobos code and saw an example. I'll look again. Thanks for the answer, Walter and Russell. John |
January 28, 2002 Re: D floating point | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter |
Walter wrote:
> Yes, you need the Lf for "long double", which matches D's "extended". -Walter
>
> Why doesn't sprintf work for you? I use it!
>
Walter
I can get sprintf to work as long as I don't have printf as well, when I get a conflict of definitions of printf between object.printf and stdio.printf.
John
|
January 28, 2002 Re: D floating point | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Fletcher | Just comment out one of them. I'll fix it at my end. -Walter "John Fletcher" <J.P.Fletcher@aston.ac.uk> wrote in message news:3C55262C.57E5ABB1@aston.ac.uk... > > > Walter wrote: > > > Yes, you need the Lf for "long double", which matches D's "extended". -Walter > > > > Why doesn't sprintf work for you? I use it! > > > > Walter > > I can get sprintf to work as long as I don't have printf as well, when I get a conflict of definitions of printf between object.printf and stdio.printf. > > John > > > |
Copyright © 1999-2021 by the D Language Foundation