Re: Number underscored gone wrong

Mage <[email protected]> Tue, 17 Sep 2019 18:08:57 +0200
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CAPuuv=xrES5hSMVsFtnUMcgNvY+Ds5dPiwW68yuTb_Pksape=g@mail.gmail.com>
And what if I write not one but two zeroes in front of it? Will it turn
into a black woman?

It must be what happened to 007

Mage



On Tue, Sep 17, 2019 at 5:16 PM Jeremy Bopp <[email protected]> wrote:

> Any number with a leading 0 is treated as an octal representation rather
> than decimal.
>
> [1] pry(main)> 0_50
> => 40
> [2] pry(main)> 050
> => 40
> [3] pry(main)> 050.to_s(10)
> => "40"
> [4] pry(main)> 050.to_s(8)
> => "50"
>
> -Jeremy
>
>
> On Tue, Sep 17, 2019 at 10:13 AM Peter L <[email protected]> wrote:
>
>> Dear ruby fans...
>>
>> Just a quick question: I always thought underscores in numbers were
>> ignored, like 100_000, 10_00 or 666_6.
>>
>> Buuut: did anyone of you tried to do following?
>>
>> > 0_50
>>
>> WTH :)
>>
>> Really - try it :)
>>
>> Would be great if someone could answer why this is not working as I
>> imagined? :)
>>
>> Have a nice afternoon!
>>
>> Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
>> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>>
>
> Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>