D - D floating point
- John Fletcher (8/8) Jan 25 2002 I am experimenting with this.
- Russell Borogove (9/13) Jan 25 2002 My guess is that, since printf is currently coming from a C
- Walter (5/18) Jan 25 2002 Yes, you need the Lf for "long double", which matches D's
- John Fletcher (6/9) Jan 28 2002 I don't know, I couldn't get it to compile, so I dug in the phobos code
- John Fletcher (6/9) Jan 28 2002 Walter
- Walter (3/14) Jan 28 2002 Just comment out one of them. I'll fix it at my end. -Walter
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". -WalterThank 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