

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
- Related Questions & Answers
- Java floor() method with Examples
- NavigableSet Class floor() method in Java
- Math Class in C#
- Java multiplyExact() in Math
- floor() function in PHP
- PHP floor() Function
- Math class methods in C#
- Math. fround() function in JavaScript
- Math. hypot() function in JavaScript
- JavaScript Math Object example
- What is math object in JavaScript?
- Math class methods in Java Programming
- Math operations for BigDecimal in Java
- Math Operations on BigInteger in Java
- What are JavaScript Math Functions?
- Ceil and floor functions in C++
Advertisements