title: Round to the next higher number
body: <p>I want to round a value (double) to the next (allways round up) number. Rounding can be defined by any number.</p>
  
  <p>Exp.:<br>
  Round up to the next 2.50<br></p>
  
  <pre><code>0.00       --&gt; 0.00
  0.01       --&gt; 2.50
  2.49       --&gt; 2.50
  2.50       --&gt; 2.50
  2.50000001 --&gt; 5.00
  ...
  </code></pre>
  
  <p>The algorithm to do this is easy (if 'number' was negative * -1):</p>
  
  <pre><code>Math.Round((Math.Abs(number) + tolerance) / 2.50, MidpointRounding.AwayFromZero) * 2.50
  </code></pre>
  
  <p>Tolerance is defined like this:</p>
  
  <pre><code>tolerance = 2.50 / 2 - Math.Pos(10, -x);
  </code></pre>
  
  <p>But I don't know how to determine x! Because in case of the 1st-4th example x should be 0.01 in case of the 5th example it should be 0.0000001 and so on...</p>
  
  <p>Search results only suggest to parse the string of a decimal number and count the decimal digit. Is there no mathematical way? Otherwise I have to treat with different locale settings for decimal seperator and numbers with no decimal digits (no decimal seperator to remove).</p>
  
  <p>May anyone has a solution for my issue. Thank you!</p>
  
  <p>Kind regards, Danny</p>