title: Clamping to next lowest value in a series
body: <p>I'm trying to clamp a number to the lower value of a series of numbers. For instance, if I have a series (sorry for the bad notation)</p>
  
  <p><code>[pq]</code> where <code>p</code> is any integer and <code>q</code> is any positive number.</p>
  
  <p>Say if <code>q is 50</code> my series will be <code>...-150, -100, -50, 0, 50, 100, 150...</code></p>
  
  <p>Now what I'd like is to have a function <code>f(y)</code> which'll clamp any number to the next lowest number in the series.</p>
  
  <p>For example, if I had the number <code>37</code> I'd be expecting the <code>f(37) = 0</code> and I'd be expecting <code>f(-37) = -50</code>.</p>
  
  <p>I've tried many algorithms involving modulus and integer division but I can't seem to figure it out. The latest I've tried is for example</p>
  
  <p><code>(37 / q) * q</code> which works great for positive numbers but doesn't work for any number between -50 and 0.</p>
  
  <p>I've also tried <code>((37 - q) / q) * q</code> but this won't work for negative cases which land exactly in the series.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Assume that I do not have the entire series but only the multiplier <code>p</code> of the series.</p>