From: Joel VanderWerf Date: 2014-08-14T18:38:05-07:00 Subject: [ruby-core:64376] Re: [ruby-trunk - Feature #10131] [Open] Greatest multiple of r not greater than x On 08/13/2014 11:32 PM, sawadatsuyoshi@gmail.com wrote: > It happens too often to me that I want to calculate the greatest multiple of numeric r not greater than numeric x. This can be done by a simple operation below: > > x, r = 3.7, 0.5 > x.div(r).*(r) #=> 3.5 > > x, r = 41, 6 > x.div(r).*(r) #=> 36 x-x%r is a bit shorter, at least.