From: Walton Hoops Date: 2009-11-28T15:06:17+09:00 Subject: Re: where is grep? > From: Ruby Newbee [mailto:rubynewbee@gmail.com] > > Thanks, that sounds be more reasonable, b/c I like to grep from an > array not a string (yes perl does this). > > btw, why 0/0 got failed but 0.0/0.0 seems valid? > > irb(main):144:0> v=0/0 > ZeroDivisionError: divided by 0 > from (irb):144:in `/' > from (irb):144 > from /usr/bin/irb:12:in `
' > > irb(main):145:0> v=0.0/0.0 > => NaN It's the difference betweeen floating point and integer arithmetic. When working with integers all results must be valid integers, whereas floating point can represent NaN (Not a Number), negative zero, and infinity and negative infinity: irb(main):001:0> 1.0/0.0 => Infinity irb(main):002:0> -0.0 => -0.0 irb(main):003:0> 0.0/-0.0 => NaN irb(main):004:0> -1.0/0.0 => -Infinity irb(main):005:0> See http://en.wikipedia.org/wiki/Floating_point for more information.