On Sun Solaris 2.6 (Sparc Ultra 1) the behavior is different:
ruby 1.6.2 (2000-12-25) [sparc-solaris2.6]
irb(main):001:0> a = -1.0
-1.0
irb(main):002:0> a.nan?
false
irb(main):003:0> a = Math.log(a)
-Infinity
irb(main):004:0> a.nan?
false
irb(main):005:0>
--Leo
>>>>> "DT" == Dave Thomas <Dave / PragmaticProgrammer.com> writes:
DT> Tammo Freese <tammo.freese / offis.de> writes:
>> After the Pickaxe Book, first print, p. 320
DT> ...
>> However, as the results of the code in the pickaxe book are generated
>> by running the code (aren't they?), 1.6.0 seems to have the correct(?)
>> behaviour (returning NaN).
DT> I just ran this again on my box here (ruby 1.6.2 (2001-02-02) [i686-linux]):
DT> a = -1.0 # => -1.0
DT> a.nan? # => false
DT> a = Math.log(a) # => NaN
DT> a.nan? # => true
DT> So, there seems to be a difference between a Linux box and a
DT> Windows/cygwin box. Anyone any ideas?
DT> Dave