Round up a number : Round « Development Class « C# / C Sharp






Round up a number

Round up a number

using System;
using System.Data;
using System.Text.RegularExpressions;

class Class1{
        static void Main(string[] args){
      Console.WriteLine(RoundUp(.4));
      Console.WriteLine(RoundUp(.5));
      Console.WriteLine(RoundUp(.6));
      Console.WriteLine(RoundUp(1.4));
      Console.WriteLine(RoundUp(1.5));
      Console.WriteLine(RoundUp(1.6));
      Console.WriteLine(RoundUp(2.4));
      Console.WriteLine(RoundUp(2.5));
      Console.WriteLine(RoundUp(2.6));
      Console.WriteLine(RoundUp(3.4));
      Console.WriteLine(RoundUp(3.5));
      Console.WriteLine(RoundUp(3.6));
        }
    public static double RoundUp(double valueToRound)
    {
      return (Math.Floor(valueToRound + 0.5));
    }

}

           
       








Related examples in the same category

1.Rounding a Floating Point ValueRounding a Floating Point Value
2.Round down a numberRound down a number