# Min

> Returns the minimum of two or more values.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## Min(float, float)

Returns the minimum of two or more values.

```csharp
public static float Min(float a, float b)
```

### Parameters

**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): First value to compare.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Second value to compare.

### Returns

| Type                                                          | Description                                       |
| ------------------------------------------------------------- | ------------------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | Smallest value found between all compared values. |

### Remarks

The resulting value will be the input value closest to '-Mathf.Infinity'.

Additional Resources: [Mathf.Max](/engine/6000.7/script-reference/unityengine/mathf/max.md).

### Examples

```csharp
using UnityEngine;

public class ScriptExample : MonoBehaviour
{
    void Start()
    {
        // Prints 0
        Debug.Log(Mathf.Min(0, Mathf.Infinity));
        // Prints -Infinity
        Debug.Log(Mathf.Min(0, -Mathf.Infinity));
        // Prints -Infinity
        Debug.Log(Mathf.Min(-Mathf.Infinity, Mathf.Infinity));
        // Prints -1
        Debug.Log(Mathf.Min(0, 1, 5, -1, 8, 10));
    }
}
```

## Min(float\[])

Returns the minimum of two or more values.

```csharp
public static float Min(params float[] values)
```

### Parameters

**** (\[float\[]]\(https\://learn.microsoft.com/dotnet/api/system.single)): Array of values to compare.

### Returns

| Type                                                          | Description                                       |
| ------------------------------------------------------------- | ------------------------------------------------- |
| [float](https://learn.microsoft.com/dotnet/api/system.single) | Smallest value found between all compared values. |

### Remarks

The resulting value will be the input value closest to '-Mathf.Infinity'.

Additional Resources: [Mathf.Max](/engine/6000.7/script-reference/unityengine/mathf/max.md).

### Examples

```csharp
using UnityEngine;

public class ScriptExample : MonoBehaviour
{
    void Start()
    {
        // Prints 0
        Debug.Log(Mathf.Min(0, Mathf.Infinity));
        // Prints -Infinity
        Debug.Log(Mathf.Min(0, -Mathf.Infinity));
        // Prints -Infinity
        Debug.Log(Mathf.Min(-Mathf.Infinity, Mathf.Infinity));
        // Prints -1
        Debug.Log(Mathf.Min(0, 1, 5, -1, 8, 10));
    }
}
```

## Min(int, int)

Returns the minimum of two or more values.

```csharp
public static int Min(int a, int b)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): First value to compare.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Second value to compare.

### Returns

| Type                                                       | Description                                       |
| ---------------------------------------------------------- | ------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Smallest value found between all compared values. |

### Remarks

The resulting value will be the input value closest to 'int.MinValue'.

Additional Resources: [Mathf.Max](/engine/6000.7/script-reference/unityengine/mathf/max.md).

### Examples

```csharp
using UnityEngine;

public class ScriptExample : MonoBehaviour
{
    void Start()
    {
        // Prints 0
        Debug.Log(Mathf.Min(0, int.MaxValue));
        // Prints -2147483648
        Debug.Log(Mathf.Min(0, int.MinValue));
        // Prints -2147483648
        Debug.Log(Mathf.Min(int.MinValue, int.MaxValue));
        // Prints -1
        Debug.Log(Mathf.Min(0, 1, 5, -1, 8, 10));
    }
}
```

## Min(int\[])

Returns the minimum of two or more values.

```csharp
public static int Min(params int[] values)
```

### Parameters

**** (\[int\[]]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Array of values to compare.

### Returns

| Type                                                       | Description                                       |
| ---------------------------------------------------------- | ------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | Smallest value found between all compared values. |

### Remarks

The resulting value will be the input value closest to 'int.MinValue'.

Additional Resources: [Mathf.Max](/engine/6000.7/script-reference/unityengine/mathf/max.md).

### Examples

```csharp
using UnityEngine;

public class ScriptExample : MonoBehaviour
{
    void Start()
    {
        // Prints 0
        Debug.Log(Mathf.Min(0, int.MaxValue));
        // Prints -2147483648
        Debug.Log(Mathf.Min(0, int.MinValue));
        // Prints -2147483648
        Debug.Log(Mathf.Min(int.MinValue, int.MaxValue));
        // Prints -1
        Debug.Log(Mathf.Min(0, 1, 5, -1, 8, 10));
    }
}
```
