[Issue 10881] Support %f formatting for a std.complex.complex

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 24 17:54:25 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10881



--- Comment #5 from hsteoh at quickfur.ath.cx 2013-08-24 17:54:23 PDT ---
Another related issue is how field widths should be handled by the formatting
functions.

Currently, toString supports a custom print format (it doesn't integrate
properly with the present std.format, but don't worry about that -- I have the
fix for that already). But it produces unexpected results: complex(1.2,
3.4).toString(null, "%5.2f") produces " 1.00+ 2.00i", because the format spec
is just propagated to the real/imaginary parts of the number. This is
unexpected because from the user's POV, the field width specifies the width for
the entire complex number, not the individual parts. I'd expect the format
"%5.2f" should mean field width of *entire* complex number is 5, with 2 digits
precision after the decimal point. So the output should be "1.00+2.00i" because
the resulting string exceeds the specified field width.

If the format was "%5.0f", I'd expect the output to be " 1+2i" (1 space padding
to fill up to field width of 5), but the current result is "    1+    2i".

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


More information about the Digitalmars-d-bugs mailing list