.Floor()
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
:
All contributors
- cslylla58 total contributions
- Anonymous contributorAnonymous contributor1 total contribution
- cslylla
- Anonymous contributor
Looking to contribute?
- 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.