From: Michael Garriss Date: 2003-08-12T11:22:02+09:00 Subject: Re: NaN and Inifinity Dan Doel wrote: > Scott Thompson wrote: > >>> irb(main):015:0> a = Math::log(-1) >>> => NaN >>> irb(main):016:0> a.class >>> => Float >>> irb(main):017:0> b = "NaN".to_f >>> => NaN >>> irb(main):018:0> b.class >>> => Float >>> irb(main):019:0> b.nan? >>> => true >> >> >> >> Hrrrm... Okee dokey. I tried something like that and I get >> >> irb(main):002:0> b = "NaN".to_f >> => 0.0 >> irb(main):003:0> b.nan? >> => false >> >> There must be something wacky with my Ruby. :-) >> >> Scott > > > It's not just you. Happens to me, too, using Ruby 1.8.0pre9 (I > believe) mswin32 build. > > Then again, Math::log(-1) throws a domain error for me. > > If worse comes to worst you could always initialize with > Math::log(-1), since that returns > what you want. > > - Dan > I got one for you. I was getting this: irb(main):001:0> a = Math::log(-1) => 3.141592653589793i irb(main):002:0> a.class => Complex irb(main):003:0> b = "NaN".to_f => 0.0 irb(main):004:0> b.class => Float irb(main):005:0> b.nan? => false Then I realized that I start irb with the -m option. Hmmm.