title: calculating prices based on usage ammount
body: <p>I'm trying to model a database charging users based on how much of a resource they consumed. I think a reasonable way of doing that is creating a table with "charge $10 per consumption up to 10, $8 per consumption up to 20 and $6 per consumption up to +MAXINT". Then if a user consumed 25, I just need to do something similar to (10 * $10 + (20-10) * $8 + (25-20) * $6).</p>
  
  <p>It seems that would work reasonably well, but what if I need to charge a fix fee no matter what? ie, "users should pay $20 (total) regardless of how much they consumed between 0 and 10, and then $8 per consumption til 20"?</p>
  
  <p>If I could assume the minimum consumption would be 1, I could do exactly as before, but set "charge $20 per consumption up to 1, $0 per consumption up to 10 and $8 per consumption up to 20". But I can't.</p>
  
  <p>So maybe I could do something similar to above, but treat "up to 0" as a special value (that wouldn't be multiplied by the unit, but by 1). Or I could try to change 1 to 0.0001 and multiply the price by 10000, but that's dirty.</p>