Comment about sprintf %u

e$B1sF#$H?=$7$^$9!#e(B

r12809 e$B$+$ie(B sprintf e$B$Ne(B %u e$B$,e(B %d
e$B$HF1$80UL#$K$J$C$?$h$&$G$9$,!"e(B
e$B%3%a%s%H$,$=$l$KDI=>$7$F$$$J$$$h$&$G$9!#e(B

Index: sprintf.c

— sprintf.c (revision 15174)
+++ sprintf.c (working copy)
@@ -221,12 +221,7 @@

  •    s   | Argument is a string to be substituted. If the format
    
  •        | sequence contains a precision, at most that many 
    

characters

  •        | will be copied.
    
    •    u   | Treat argument as an unsigned decimal number. Negative 
      

integers

    •        | are displayed as a 32 bit two's complement plus one for 
      

the

    •        | underlying architecture; that is, 2 ** 32 + n. 
      

However, since

    •        | Ruby has no inherent limit on bits used to represent 
      

the

    •        | integer, this value is preceded by two dots (..) in 
      

order to

    •        | indicate a infinite number of leading sign bits.
      
    •    u   | Identical to `d'.
      
    •    X   | Convert argument as a hexadecimal number using 
      

uppercase

  •        | letters. Negative numbers will be displayed with two
    
  •        | leading periods (representing an infinite string of
    

@@ -243,7 +238,7 @@

  • sprintf("%1$*2$s %2$d %1$s", "hello", 8)   #=> "   hello 8 
    

hello"

  • sprintf("%1$*2$s %2$d", "hello", -8)       #=> "hello    -8"
    
  • sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23)   #=> "+1.23: 
    

1.23:1.23"

    • sprintf("%u", -123)                        #=> "..4294967173"
      
    • sprintf("%u", -123)                        #=> "-123"
      
    */

VALUE

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:33275] comment about sprintf %u”
on Tue, 22 Jan 2008 23:23:34 +0900, “Yusuke ENDOH” [email protected]
writes:

|r12809 e$B$+$ie(B sprintf e$B$Ne(B %u e$B$,e(B %d e$B$HF1$80UL#$K$J$C$?$h$&$G$9$,!"e(B
|e$B%3%a%s%H$,$=$l$KDI=>$7$F$$$J$$$h$&$G$9!#e(B

e$B%3%_%C%H$7$F$/[email protected]$5$$!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs