This C# program demonstrates how to use some of the simple math functions in C#.
using System;
namespace XoaX {
class Program {
static void Main(string[] args) {
double dX = -371.495;
double dY = 59.3871;
Console.WriteLine("The absolute value of " + dX + " is " + Math.Abs(dX));
Console.WriteLine("The absolute value of " + dY + " is " + Math.Abs(dY));
Console.WriteLine("The ceiling of " + dX + " is " + Math.Ceiling(dX));
Console.WriteLine("The ceiling of " + dY + " is " + Math.Ceiling(dY));
Console.WriteLine("The floor of " + dX + " is " + Math.Floor(dX));
Console.WriteLine("The floor of " + dY + " is " + Math.Floor(dY));
Console.WriteLine("The sign of " + dX + " is " + Math.Sign(dX));
Console.WriteLine("The sign of " + dY + " is " + Math.Sign(dY));
Console.WriteLine("The truncation of " + dX + " is " + Math.Truncate(dX));
Console.WriteLine("The truncation of " + dY + " is " + Math.Truncate(dY));
Console.WriteLine("The max of " + dX + " and " + dY + " is " + Math.Max(dX, dY));
Console.WriteLine("The min of " + dX + " and " + dY + " is " + Math.Min(dX, dY));
}
}
}
The absolute value of -371.495 is 371.495 The absolute value of 59.3871 is 59.3871 The ceiling of -371.495 is -371 The ceiling of 59.3871 is 60 The floor of -371.495 is -372 The floor of 59.3871 is 59 The sign of -371.495 is -1 The sign of 59.3871 is 1 The truncation of -371.495 is -371 The truncation of 59.3871 is 59 The max of -371.495 and 59.3871 is 59.3871 The min of -371.495 and 59.3871 is -371.495 Press any key to continue . . .
© 20072025 XoaX.net LLC. All rights reserved.