B
Brooks Davis
--AqsLC8rIMeq19msA
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
The behavior of sprintf("%d", str) is not what I would expect. If str
begins with a '0', for example "01", it is treated as an octal number.
This seem odd because I would expect the following two lines to be the
same:
sprintf("%d", str)
sprintf("%d", str.to_i)
This is not the case:
irb(main):006:0> str=3D"08"
=3D> "08"
irb(main):007:0> sprintf("%d", str)
ArgumentError: invalid value for Integer: "08"
from (irb):7:in `sprintf'
from (irb):7
irb(main):008:0> sprintf("%d", str.to_i)
=3D> "8"
irb(main):009:0> str=3D"010"
=3D> "010"
irb(main):010:0> sprintf("%d", str)
=3D> "8"
irb(main):011:0> sprintf("%d", str.to_i)
=3D> "10"
The seems to violate POLA. In my case it was quite astonishing because
I had a script where I parse strings like "r01rpc2" to find the rack and
power controller number from a string. When I added my eighth rack, the
script stopped working after several years of operation. Is this
behavior intended? The documentation on rubycentral doesn't really say
one way or another.
In case it matters, my ruby version is:
[12:15pm] brooks@minya (~/working/cluster/power): ruby -v
ruby 1.8.2 (2004-07-29) [i386-freebsd6]
Thanks,
Brooks
--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4
--AqsLC8rIMeq19msA
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFB+Ck7XY6L6fI4GtQRAr1jAKCRKwb88oqvxodvspsshxHYfdBUNACg3VlP
ndBgPr5C27CZqFGMka/Y+mw=
=UnMH
-----END PGP SIGNATURE-----
--AqsLC8rIMeq19msA--
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
The behavior of sprintf("%d", str) is not what I would expect. If str
begins with a '0', for example "01", it is treated as an octal number.
This seem odd because I would expect the following two lines to be the
same:
sprintf("%d", str)
sprintf("%d", str.to_i)
This is not the case:
irb(main):006:0> str=3D"08"
=3D> "08"
irb(main):007:0> sprintf("%d", str)
ArgumentError: invalid value for Integer: "08"
from (irb):7:in `sprintf'
from (irb):7
irb(main):008:0> sprintf("%d", str.to_i)
=3D> "8"
irb(main):009:0> str=3D"010"
=3D> "010"
irb(main):010:0> sprintf("%d", str)
=3D> "8"
irb(main):011:0> sprintf("%d", str.to_i)
=3D> "10"
The seems to violate POLA. In my case it was quite astonishing because
I had a script where I parse strings like "r01rpc2" to find the rack and
power controller number from a string. When I added my eighth rack, the
script stopped working after several years of operation. Is this
behavior intended? The documentation on rubycentral doesn't really say
one way or another.
In case it matters, my ruby version is:
[12:15pm] brooks@minya (~/working/cluster/power): ruby -v
ruby 1.8.2 (2004-07-29) [i386-freebsd6]
Thanks,
Brooks
--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529 9BF0 5D8E 8BE9 F238 1AD4
--AqsLC8rIMeq19msA
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQFB+Ck7XY6L6fI4GtQRAr1jAKCRKwb88oqvxodvspsshxHYfdBUNACg3VlP
ndBgPr5C27CZqFGMka/Y+mw=
=UnMH
-----END PGP SIGNATURE-----
--AqsLC8rIMeq19msA--