Actions
Bug #11293
closedInteger('0123') => 83
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
Description
Is this the correct behavior?
irb(main):001:0> Integer('0123')
=> 83
Shouldn't the return value be 123
?
Updated by jeremyevans0 (Jeremy Evans) almost 10 years ago
Matt Di Pasquale wrote:
Is this the correct behavior?
irb(main):001:0> Integer('0123') => 83
Shouldn't the return value be
123
?
No, 83 would be the expected result, just as if you specified 0123 in ruby code. Kernel#Integer treats a leading 0 to mean octal, leading 0x to mean hexidecimal, and leading 0b to mean binary, just as ruby itself does.
Updated by nobu (Nobuyoshi Nakada) almost 10 years ago
- Status changed from Open to Rejected
Try Integer('0123', 10)
.
Updated by mattdipasquale (Matthew Mario Di Pasquale) over 8 years ago
Got it. Thank you. :-)
Actions
Like0
Like0Like0Like0