www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5237] New: writefln doesn't respect Complex.toString

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237

           Summary: writefln doesn't respect Complex.toString
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au



import std.complex;
import std.stdio;

void main()
{
     cdouble z2 = 10 + 1.5e-6i;
     Complex!(double) z;
     z.re = 10;
     z.im = 1.5e-6;
     writefln("z= %.16f z2 = %.16f", z, z2);
    writefln("z = %f z2 = %f", z, z2);
    writefln("z = %e z2 = %e", z, z2);
    writefln("z = %a z2 = %a", z, z2);
} 

z = 10+1.5e-06i z2 = 10.0000000000000000+0.0000015000000000i 
z = 10+1.5e-06i z2 = 10.000000+0.000001i
z = 10+1.5e-06i z2 = 1.000000e+01+1.500000e-06i
z = 10+1.5e-06i z2 = 0x1.4p+3+0x1.92a737110e454p-20i 

Clearly the format string is not being passed, or is being ignored.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237




Partial fix in svn 2183. This fixes the last 3 cases, not the first one.
It would be very straightforward to implement the first case, but we need to
think if it would really be a sensible design, since we'd be doing
atoi(itoa(atoi(original_string))).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



*** Issue 5231 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237


Lars T. Kyllingstad <bugzilla kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla kyllingen.net



02:26:47 PST ---

 Partial fix in svn 2183. This fixes the last 3 cases, not the first one.
 It would be very straightforward to implement the first case, but we need to
 think if it would really be a sensible design, since we'd be doing
 atoi(itoa(atoi(original_string))).
Couln't that be easily solved by storing the full format string in FormatSpec? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237






 Partial fix in svn 2183. This fixes the last 3 cases, not the first one.
 It would be very straightforward to implement the first case, but we need to
 think if it would really be a sensible design, since we'd be doing
 atoi(itoa(atoi(original_string))).
Couln't that be easily solved by storing the full format string in FormatSpec?
Probably. My guess is that positional parameters will make it more complicated, but possibly it's really simple. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237




04:32:21 PST ---

 My guess is that positional parameters will make it more complicated,
 but possibly it's really simple.
Regarding positional parameters, allow me to restate a point I made in the DIP9 thread on the newsgroup: I think it's best to leave out the '%' from the format string that is sent to toString(). This will facilitate the use of positional parameters, in which the percent is followed by a position specifier which necessarily has to be handled at a higher level than toString(). Example: BigInt i = "456"; BigInt j = "123"; writefln("%2$s %1$s", i, j); // Prints "123 456" The only thing BigInt.writeTo() needs to see is the part after the '$' character. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237




04:35:04 PST ---


 Partial fix in svn 2183. This fixes the last 3 cases, not the first one.
 It would be very straightforward to implement the first case, but we need to
 think if it would really be a sensible design, since we'd be doing
 atoi(itoa(atoi(original_string))).
Couln't that be easily solved by storing the full format string in FormatSpec?
One problem is of course when the user passes a non-immutable format string, as in char[] fmt = "%s %s".dup; writefln(fmt, 1, 3.14); Then each format specifier has to be dup-ed before being stored in FormatSpec. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 19 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei metalanguage.com
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 09 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



https://github.com/D-Programming-Language/phobos/pull/126

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 02 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5237


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED



https://github.com/D-Programming-Language/phobos/commit/4c8cbd2f29637abfadb2d3057a5e747fe8084d4d

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 10 2011