From: Phrogz Date: 2007-08-15T01:45:00+09:00 Subject: Re: how to output a octal coded number ??? On Aug 14, 6:56 am, unbewust wrote: > On 14 ao�t, 11:31, Eric Hodel wrote: > > The easiest way will probably be to use sprintf. From C, use > > rb_f_sprintf. > OK, thanks, but i don't want to print it just have it as a return > value then you mean i can use sprintf to print to stdout and the value > will be cached by Ruby ? Despite the name, sprintf does not actually print the value to stdout. I prefer its more terse version, String#%: C:\>irb irb(main):001:0> n = 509 => 509 irb(main):002:0> s = "%04o" % n => "0775" For more info, "ri sprintf" or "ri String#%"