Integers with preceding zero don't return as expected?

09:02:40 ~ $ irb

07023
=> 3603

Thoughts? Huh?
-R

Roger P. ha scritto:

09:02:40 ~ $ irb

07023

=> 3603

Thoughts? Huh?
-R

With a preceding zero you are specifying an octal digit.

Andrea

On Fri, May 9, 2008 at 12:09 AM, Roger P. [email protected]
wrote:

A leading zero makes it octal.

Harry

A leading zero makes it octal.
Thanks guys.
-R

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Roger P. 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 G.
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.”
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgjG9cACgkQbtAgaoJTgL9gcwCfRzPMYBHE1OVCJ5h+Ti6oq2iI
ci8An3KmX/NO/ys8e9eulNHUEz9eek+J
=IMZQ
-----END PGP SIGNATURE-----