Thread overview
[Issue 8531] New: formatting string documentation
Aug 10, 2012
bioinfornatics
Oct 27, 2012
Kenji Hara
August 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8531

           Summary: formatting string documentation
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bioinfornatics@gmail.com


--- Comment #0 from bioinfornatics <bioinfornatics@gmail.com> 2012-08-10 03:39:04 PDT ---
Dear,

In this documentation http://dlang.org/phobos/std_format.html#format-string They do not talk about %u for unsigned number. %u works well with both readf and writef

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8531


hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx


--- Comment #1 from hsteoh@quickfur.ath.cx 2012-10-27 09:04:03 PDT ---
Actually, I think %u is redundant. std.format uses compile-time introspection to do the "right thing" for %d. You can pass an unsigned number for %d and it works correctly. I just tested %u, it seems that it's just an alias for %d:

int a = -10;
writefln("%u", a); // outputs "-10"

So I think this bug is invalid.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 27, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8531


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-10-27 09:26:22 PDT ---
(In reply to comment #1)
> Actually, I think %u is redundant. std.format uses compile-time introspection to do the "right thing" for %d. You can pass an unsigned number for %d and it works correctly. I just tested %u, it seems that it's just an alias for %d:
> 
> int a = -10;
> writefln("%u", a); // outputs "-10"
> 
> So I think this bug is invalid.

Yes. And, if programmer really want to format int value as unsigned, he needs to use cast instead of %u.

writefln("%d", cast(uint)a); // outputs "4294967286"

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