- 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
Math.Floor() Method in C#
The Math.Floor() method in C# is used to return the largest integral value less than or equal to the specified number.
Syntax
public static decimal Floor (decimal val); public static double Floor (double val)
For the first syntax above, the value val is the decimal number, whereas Val in the second syntax is the double number.
Let us now see an example to implement Math.Floor() method −
Example
using System; public class Demo { public static void Main(){ decimal val1 = 7.10M; decimal val2 = -79.89M; Console.WriteLine("Result = " + Math.Floor(val1)); Console.WriteLine("Result = " + Math.Floor(val2)); } }
Output
This will produce the following output −
Result = 7 Result = -80
Let us see another example to implement Math.Floor() method −
Example
using System; public class Demo { public static void Main(){ double val1 = 8.9; double val2 = 88.10; double val3 = -31.98; Console.WriteLine("Result = " + Math.Floor(val1)); Console.WriteLine("Result = " + Math.Floor(val2)); Console.WriteLine("Result = " + Math.Floor(val3)); } }
Output
This will produce the following output −
Result = 8 Result = 88 Result = -32
Advertisements