Decimal Functions in C#

CsharpProgrammingServer Side Programming

The following are some of the decimal functions in C#.

Sr.No.Name & Description
1Add (Decimal, Decimal)
Adds two specified Decimal values.
2Ceiling(Decimal)


Returns the smallest integral value that is greater than or equal to the specified decimal number.
3Compare (Decimal, Decimal)
Compares two specified Decimal values.
4CompareTo(Decimal)
Compares this instance to a specified Decimal object and returns a comparison of their relative values.
5CompareTo(Object)
Compares this instance to a specified object and returns a comparison of their relative values.
6Divide (Decimal, Decimal)
Divides two specified Decimal values.
7Equals(Decimal)
Returns a value indicating whether this instance and a specified Decimal object represent the same value.

Let us see an example of Decimal Ceiling() method in C# that returns the smallest integral value greater than or equal to the specified decimal number.

Example

 Live Demo

using System;
class Program {
   static void Main() {
      Console.WriteLine(decimal.Ceiling(1.2M));
   }
}

Output

2
raja
Published on 17-Sep-2018 12:05:13
Advertisements