Rounding a Floating Point Value
using System;
using System.Data;
using System.Text.RegularExpressions;
class Class1{
static void Main(string[] args){
int X = (int)Math.Round(2.5555);
Console.WriteLine(X);
Console.WriteLine(Math.Round(2.5555, 2));
Console.WriteLine(Math.Round(2.444444,3));
Console.WriteLine(Math.Round(2.666666666666666666666666666660001));
Console.WriteLine(Math.Round(2.4444444444444444444444440001));
Console.WriteLine(Math.Round(.5));
Console.WriteLine(Math.Round(1.5));
Console.WriteLine(Math.Round(2.5));
Console.WriteLine(Math.Round(3.5));
Console.WriteLine();
Console.WriteLine(Math.Floor(.5));
Console.WriteLine(Math.Floor(1.5));
Console.WriteLine(Math.Floor(2.5));
Console.WriteLine(Math.Floor(3.5));
Console.WriteLine();
Console.WriteLine(Math.Ceiling(.5));
Console.WriteLine(Math.Ceiling(1.5));
Console.WriteLine(Math.Ceiling(2.5));
Console.WriteLine(Math.Ceiling(3.5));
Console.WriteLine();
}
}
|
HTML code for linking to this page:
Related in same category :
-
|