From: unbewust Date: 2007-08-15T00:35:04+09:00 Subject: Re: how to output a octal coded number ??? On 14 ao�t, 16:55, Simon Krahnke wrote: > * unbewust (10:46) schrieb: > > > 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 ??? > > A integer in ruby is a numeric value, it's not octal or decimal. > > > thought, at that time i'm usinbg INT2FIX ( ) > > A string representation of a number can be octal or decimal or whatever. > The Ruby as well and the C library have means to convert between numbers > and its string representations. OK thanks the reason for me to output as an octal number it is an habit when talking about perms... i'll look at the C library to output that the correct way. > num = "775".to_i(8) > dec = num.to_s #> "509" > oct = num.to_s(8) #> "775" i've allready a way to output my number as an octal "775" BUT i'll like having better "0775" because in the C language the first 0 means octal and i ask for xhen input . > mfg, simon .... l > > > best > > > Yvon > > BTW: The german word unbewusst is written with two s. :-) yes i know, i didn't cacht my misspelling ;-) vielen dank ;-) Yvon