From: "David N. Springer" Date: 2004-10-01T00:55:30+09:00 Subject: Re: Range syntax theory Austin Ziegler wrote: >On Thu, 30 Sep 2004 22:58:26 +0900, Henrik Horneber wrote: > > >> From an intellectual point I sort of understand the '..' and '..' >>notation. What distracts me most, is the visual difference ... that the >>visually longer three dot form contains fewer elements than the shorter >>two dot form. >> >>(1..5).to_a >>=>[1,2,3,4,5] >>(1...5).to_a >>=>[1,2,3,4] >> >> > >That's a dangerous consideration -- and not always true: > >irb(main):001:0> (1..5).include?(4.99) >=> true >irb(main):002:0> (1...5).include?(4.99) >=> true >irb(main):003:0> > >1...5 doesn't include only the numbers 1, 2, 3, and 4 -- it contains >the infinities between the numbers, and the infinity between 4 and 5, >but not 5 itself. > >-austin > > I see the distinction but a some point the reality of the limits of the internal representation lets us down: irb(main):001:0> (1...5).include?(4.999999999999999) => true irb(main):002:0> (1...5).include?(4.9999999999999999) => false irb(main):003:0> 4.999999999999999 < 5 => true irb(main):004:0> 4.9999999999999999 < 5 => false irb(main):005:0> -- David N. Springer