/// <summary>
/// Determines if is between the specified float is between two given floats.
/// </summary>
/// <returns><c>true</c> if the float is between the specified num lower upper inclusive; otherwise, <c>false</c>.</returns>
/// <param name="num">Number.</param>
/// <param name="lower">Lower.</param>
/// <param name="upper">Upper.</param>
/// <param name="inclusive">If set to <c>true</c> inclusive.</param>
public static bool IsBetween (this float num, float lower, float upper, bool inclusive = false)
{
return inclusive
? lower <= num && num <= upper
: lower < num && num < upper;
}
Created
February 7, 2016 23:34
-
-
Save Ashwinning/24986d9aeb01261e1420 to your computer and use it in GitHub Desktop.
IsBetween : C# extension method for `float` which checks whether that float is between a min and max value.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment