nobu.nokada / softhome.net wrote:
> 
> Hi,
> 
> At Fri, 11 Jan 2002 01:59:41 +0900,
> Tobias Reif <tobiasreif / pinkjuice.com> wrote:
> > > class String
> > >   def to_number
> > >     Integer(self) rescue Float(self) rescue self
> > >   end
> > > end
> >
> > Elegance lies in the beauty of condensed truth :)
> 
> I found;
> 
>   "0x_0".to_number      # => 0.0
>   "0x1.0".to_number     # => 0.0
>   "0x1.01".to_number    # => 1.00390625
> 
> strtod() on Linux (or glibc) seems to accept radix prefix.
> Is this Linux specific?  Also intended?

At least it doesn't work that way on my Win2K box running the Pragmatic Ruby
installation 1.6.5.2:

irb(main):042:0> class String
irb(main):043:1>   def to_number
irb(main):044:2>     Integer(self) rescue Float(self) rescue self
irb(main):045:2>   end
irb(main):046:1> end
nil
irb(main):047:0> "0x1.01".to_number
"0x1.01"
irb(main):048:0>

Too bad... Should've been 1.00390625, I think.

Stephan