Decimal Functions in C#



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

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


Returns the smallest integral value that is greater than or equal to the specified decimal number.
3 Compare (Decimal, Decimal)
Compares two specified Decimal values.
4 CompareTo(Decimal)
Compares this instance to a specified Decimal object and returns a comparison of their relative values.
5 CompareTo(Object)
Compares this instance to a specified object and returns a comparison of their relative values.
6 Divide (Decimal, Decimal)
Divides two specified Decimal values.
7 Equals(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
Updated on: 2020-06-23T09:44:15+05:30

231 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements