Thread overview
floating point bug
Feb 11, 2004
imr1984
Feb 11, 2004
davepermen
Feb 11, 2004
Sean Kelly
February 11, 2004
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);
}


February 11, 2004
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);
> }
>
>


February 11, 2004
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