MathF.Min() Method in C# with Examples

In C#, Min(Single, Single) is a MathF class method which is used to returns the minimum of the two specified numbers.

Syntax: public static float Min (float x, float y);
Here, x and y are the two floating point numbers which are compared.

Return Type: This method returns the minimum of the two numbers which specified into the parameter list and return type depends on the type of arguments passed.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# program to demonstrate the
// MathF.Min(Single, Single) method
using System;
  
class GFG {
  
    // Main Method
    static void Main()
    {
        // taking different float values
        float f1 = 56.48f, f2 = 78.123457f;
        float f3 = -785.2f, f4 = -58.2547f;
  
        // displaying result
        Console.WriteLine(MathF.Min(f1, f2));
        Console.WriteLine(MathF.Min(f3, f4));
    }
}

chevron_right


Output:

56.48
-785.2


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.