From: sto.mar@... Date: 2012-12-22T20:08:47+09:00 Subject: Re: simple division: -9 / 5 = -2 what? Am 22.12.2012 11:55, schrieb Alan Forrester: > > On 22 Dec 2012, at 08:45, sto.mar@web.de wrote: > >> Am 22.12.2012 07:11, schrieb rubyinfo: >>> I believe ruby followed c in the convention of integer/integer => integer >>> so you get 9/5 => 2 >> >> No, 9 / 5 => 1 ! >> >> Integer division with quotient 1, remainder (modulus) 4. > > What appears to happen is that Ruby does the division and rounds down to the nearest integer. > > Alan See `ri Numeric#divmod' for a detailed description and examples: for integers a and b, a/b returns floor(a/b). (Also note that remainder and modulus are not the same.) --