public Method

Fixnum.to_s(...)

fix.to_s( base=10 )  aString

Returns a string containing the representation of fix radix base (between 2 and 36).

12345.to_s       #=> "12345"
12345.to_s(2)    #=> "11000000111001"
12345.to_s(8)    #=> "30071"
12345.to_s(10)   #=> "12345"
12345.to_s(16)   #=> "3039"
12345.to_s(36)   #=> "9ix"

Source Code

/*
*  call-seq:
*     fix.to_s( base=10 ) -> aString
*  
*  Returns a string containing the representation of <i>fix</i> radix
*  <i>base</i> (between 2 and 36).
*     
*     12345.to_s       #=> "12345"
*     12345.to_s(2)    #=> "11000000111001"
*     12345.to_s(8)    #=> "30071"
*     12345.to_s(10)   #=> "12345"
*     12345.to_s(16)   #=> "3039"
*     12345.to_s(36)   #=> "9ix"
*
*/
static VALUE
fix_to_s(argc, argv, x)
   int argc;
   VALUE *argv;
   VALUE x;
{
   VALUE b;
   int base;

   rb_scan_args(argc, argv, "01", &b);
   if (argc == 0) base = 10;
   else base = NUM2INT(b);

   return rb_fix2str(x, base);
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.