Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Float printing bug

Moderators: kris

Posted: 03/31/08 04:20:20

For some reason, floating point values do not print correctly. Example code:

module floattest;

import tango.io.Stdout;

void main(){
	float x = 3.14;
	double y = 3.14;
	Stdout(x).newline;
	Stdout(y).newline;
	Stdout(cast(double)x).newline;
}

The output on my computer is:

2.14
3.14
3.14

When 3.14 in both places is replaced with 2.2 the output is:

2.02
2.20
2.20

I think something is wrong here! I am compiling with dsss and running on a PPC Mac OS 10.4 system. Using the latest tango release.

Author Message

Posted: 03/31/08 05:41:25

Please create a ticket with the above?

As for the reason, GDC has a history of buggy float handling, so the problem may be there, although I won't draw any hasty conclusions on the matter.