Integers with preceding zero don't return as expected?

09:02:40 ~ $ irb

07023

=> 3603

Thoughts? Huh?
-R

···

--
Posted via http://www.ruby-forum.com/\.

Roger Pack ha scritto:

09:02:40 ~ $ irb
  

07023
      

=> 3603

Thoughts? Huh?
-R
  
With a preceding zero you are specifying an octal digit.

Andrea

A leading zero makes it octal.

Harry

···

On Fri, May 9, 2008 at 12:09 AM, Roger Pack <rogerpack2005@gmail.com> wrote:

09:02:40 ~ $ irb
>> 07023
=> 3603

Thoughts? Huh?
-R
--
Posted via http://www.ruby-forum.com/\.

--
A Look into Japanese Ruby List in English

Roger Pack wrote:

09:02:40 ~ $ irb

07023

=> 3603

Thoughts? Huh?
-R

Implicit conversion of an octal number to a decimal, looks like.

07023 octal is 3603 decimal.

A leading 0 usually signifies the use of octal, instead of decimal
numbers, so Ruby does the right thing, just not in the way expected.

- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan
Blog: http://justarubyist.blogspot.com

~ - You know you've been hacking too long when...
...you "woke up" this morning and thought, "I'll checkpoint here, snooze
a bit more and then revert to checkpoint." A while later you go up
another consciousness notch and realize that you hadn't checkpointed
successfully - "Oh, of course. I didn't have the keyboard."

A leading zero makes it octal.

Thanks guys.
-R

···

--
Posted via http://www.ruby-forum.com/\.