title: How do I round a decimal to a specific fraction in C#?
body: <p>In C# rounding a number is easy:</p>
  
  <pre><code>Math.Round(1.23456, 4); // returns 1.2346
  </code></pre>
  
  <p>However, I want to round a number such that the fractional part of the number rounds to the closest fractional part of a predefined fraction (e.g. 1/8th) and I'm trying to find out if the .NET library already has this built in.</p>
  
  <p>So, for example, if I want to round a decimal number to a whole eighth then I'd want to call something like:</p>
  
  <pre><code>Math.RoundFractional(1.9, 8); // and have this yield 1.875
  Math.RoundFractional(1.95, 8); // and have this yield 2.0
  </code></pre>
  
  <p>So the first param is the number that I want to round and the second param dictates the rounding fraction. So in this example, after rounding has taken place the figures following the decimal point can only be one of eight values: .000, .125, .250, .375, .500, .625, .750, .875</p>
  
  <p>The Questions: Is this function built into .NET somewhere? If not, does anybody have a link to a resource that explains how to approach solving this problem?</p>