From: Sam Roberts Date: 2004-06-04T02:29:25+09:00 Subject: Re: [RCR] Floating point division operator /. (or fdiv method) Quoteing oinkoink+unet@rexx.com, on Fri, Jun 04, 2004 at 02:08:39AM +0900: > Michael Neumann wrote in message news:<20040602165312.GA25813@miya.intranet.ntecs.de>... > > > IMHO, even better would be if / would always mean floating point > > division and an extra // operator would mean integer division, but it's > > to late to change now (even for Ruby 2.0) :-) > > We already have .div for integer division. (13.div(7) == 2) > / has an established meaning in the mathn library: 13/7 is the > rational number 13/7. Since the standard libraries give wrong > answers when mathn is not required (and no one seems to have the > slightest interest in fixing them), the mathn meaning must be > the standard meaning. NEVER use / for integer division: > use .div instead. / has always done what it is supposed to for me: % irb irb(main):001:0> 3/2 => 1 irb(main):002:0> 3.div(2) => 1 I tried this with mathn, and got: irb(main):003:0> require "mathn" => true irb(main):004:0> 3/2 => 3/2 Its great that ruby allows programmers to extend even the standard types... but it can be pretty harmful! I would expect that after mathn is required much code would break... is that what you meant? You seemed to suggest that things would work BETTER when integer division is redefined to not do what it usually does! Cheers, Sam