www.digitalmars.com         C & C++   DMDScript  

D - floating point bug

reply imr1984 <imr1984_member pathlink.com> writes:
the following code does not run as expected, it should print out "-1" twice, but
it prints out -1 followed by 0. Its probably a bug with toString



import std.c.stdio;
import std.string;

void test(float f)
{
printf("%f\n", f);
printf("%s\n", toStringz(toString(f)));
}

void main()
{
test(-1);
}
Feb 11 2004
parent reply "davepermen" <davepermen hotmail.com> writes:
doesn't toString only take an uint (and thus casts it?)

could be manfred hit a much bigger issue. namely floating point conversions
in general.

dunno.. it's late again:D

"imr1984" <imr1984_member pathlink.com> schrieb im Newsbeitrag
news:c0e19a$j8u$1 digitaldaemon.com...
 the following code does not run as expected, it should print out "-1"
twice, but
 it prints out -1 followed by 0. Its probably a bug with toString



 import std.c.stdio;
 import std.string;

 void test(float f)
 {
 printf("%f\n", f);
 printf("%s\n", toStringz(toString(f)));
 }

 void main()
 {
 test(-1);
 }
Feb 11 2004
parent Sean Kelly <sean ffwd.cx> writes:
davepermen wrote:
 doesn't toString only take an uint (and thus casts it?)
 
 could be manfred hit a much bigger issue. namely floating point conversions
 in general.
AFAIK there are no floating point conversions in Phobos yet, unless you count streams. I assume they're on the to-do list. Sean
Feb 11 2004