[Issue 1668] New: std.stream readf can't read int, nan, inf as floats
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 13 16:51:58 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1668
Summary: std.stream readf can't read int, nan, inf as floats
Product: D
Version: 1.023
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: wbaxter at gmail.com
std.stream readf can't read int, nan, inf as floats.
This means that readf can't read in everything that writef prints out, even if
you know the exact order of elements in the stream.
Here are some tests:
//===========================================================================
module rwnans;
import std.stdio;
import std.stream;
void try_rwop(float x, string fmt="")
{
writefln("--- Test x=%f", x);
auto S = new MemoryStream();
S.writef(fmt, x);
S.position = 0;
writefln("S buffer contains '%s'", S.readLine());
S.position = 0;
float y;
int got = S.readf(&y);
writefln("read %d bytes, got y = %s", got, y);
}
void main()
{
try_rwop(1.0);
try_rwop(1.0,"%f");
float x; // nan
try_rwop(x);
try_rwop(x,"%f");
x = 1.0/0.0 ; // inf
try_rwop(x);
try_rwop(x,"%f");
try_rwop(-x);
try_rwop(-x,"%f");
}
--
More information about the Digitalmars-d-bugs
mailing list