![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Decimal.Floor() Method in C#
The Decimal.Floor() method in C# rounds a specified Decimal number to the closest integer toward negative infinity.
Syntax
Following is the syntax −
public static decimal Floor (decimal val);
Above, Val is the value to round.
Example
Let us now see an example to implement the Decimal.Floor() method −
using System; public class Demo { public static void Main(){ Decimal val1 = 25.25m; Decimal val2 = 11.85m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("Floor (val1) = "+Decimal.Floor(val1)); Console.WriteLine("Floor (val2) = "+Decimal.Floor(val2)); } }
Output
This will produce the following output −
Decimal 1 = 25.25 Decimal 2 = 11.85 Floor (val1) = 25 Floor (val2) = 11
Example
Let us now see another example to implement the Decimal.Floor() method −
using System; public class Demo { public static void Main(){ Decimal val1 = -25.25m; Decimal val2 = -11.85m; Console.WriteLine("Decimal 1 = "+val1); Console.WriteLine("Decimal 2 = "+val2); Console.WriteLine("Floor (val1) = "+Decimal.Floor(val1)); Console.WriteLine("Floor (val2) = "+Decimal.Floor(val2)); } }
Output
This will produce the following output −
Decimal 1 = -25.25 Decimal 2 = -11.85 Floor (val1) = -26 Floor (val2) = -12
Advertisements