On Wed, Sep 10, 2008 at 9:24 AM, Jan Pilz <pilz / osp-dd.de> wrote:
> Can you please explain this behaviour ?
>
> irb(main):017:0> 071.to_s
> => "57"
> irb(main):018:0> 71.to_s
> => "71"
>
> Why is an octal Number converted to decimal when outputted as String ?

Leave off the to_s:

>> 071
=> 57

You can represent your numbers in octal by putting a leading 0, but
they will be accessed as decimal numbers throughout your application.
If you want to display (any) number as octal, just use:

>> 071.to_s(8)
=> "71"
>> 57.to_s(8)
=> "71"


-- 
Technical Blaag at: http://blog.majesticseacreature.com | Non-tech
stuff at: http://metametta.blogspot.com