From: Eric Hodel Date: 2007-08-14T18:31:50+09:00 Subject: Re: [C ext to Ruby] how to output a octal coded number ??? On Aug 14, 2007, at 01:49, unbewust wrote: > i write a C extension to Ruby, some methods are dealing with octal > number (bytes in english ?) for the file permission : > > ie something like that : > > 0777 or 0644 the first 0 (zero) meaning the following is a number > coded in octal. > > > that's OK for input of octal number if for example, from ruby the user > write : > > this_file.perms = 0777 (then with the first 0) > > i get the right number > > however, for the time being, i'm returning, for the same value : > > 777 instead of 0777 when the user wants to read the perms,, then my > question how to return within a C est to Ruby an integer coded in > octal ??? > > thought, at that time i'm usinbg INT2FIX ( ) The easiest way will probably be to use sprintf. From C, use rb_f_sprintf. -- Poor workers blame their tools. Good workers build better tools. The best workers get their tools to do the work for them. -- Syndicate Wars