.Floor()
Published Feb 20, 2023Updated Mar 31, 2023
Contribute to Docs
Math.Floor()
is a static method that rounds down and returns the largest whole integer that is less than or equal to the given number.
Syntax
Math.Floor(x);
- The
Math.Floor()
method is used to find the largest whole integer that is less than or equal to the argument,x
, passed in. The argument can be of afloat
ordouble
type. - The
System
namespace is required to access this method.
Example
The following example uses Math.Floor()
to return the largest whole number.
// Include the System namespaceusing System;public class Floor {public static void Main() {Console.WriteLine(Math.Floor(5.05));}}
The example will result in the following output:
5
Codebyte Example
The following example is runnable and uses the Math.Floor()
method to return the largest whole number that is less than or equal to the given double
type number
:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C# on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn C#
Learn Microsoft's popular C# programming language, used to make websites, mobile apps, video games, VR, and more.Beginner Friendly23 hours