D - D floating point
- John Fletcher <J.P.Fletcher aston.ac.uk> Jan 25 2002
- Russell Borogove <kaleja estarcion.com> Jan 25 2002
- "Walter" <walter digitalmars.com> Jan 25 2002
- John Fletcher <J.P.Fletcher aston.ac.uk> Jan 28 2002
- John Fletcher <J.P.Fletcher aston.ac.uk> Jan 28 2002
- "Walter" <walter digitalmars.com> Jan 28 2002
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
Jan 25 2002
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
Jan 25 2002
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
Jan 25 2002
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
Jan 28 2002
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
Jan 28 2002
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
Jan 28 2002









John Fletcher <J.P.Fletcher aston.ac.uk> 