Add float/double.ToBoolean

This commit is contained in:
Oliver Booth 2021-03-16 15:02:41 +00:00
parent 1ee7e59f91
commit 27a370cffe
2 changed files with 24 additions and 0 deletions

View File

@ -130,6 +130,18 @@ namespace X10D.DoubleExtensions
return Math.Round(value / nearest) * nearest;
}
/// <summary>
/// Converts the value of the current double-precision floating-point number to an equivalent Boolean value.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <see langword="true" /> if <paramref name="value" /> is not zero, or <see langword="false" /> otherwise.
/// </returns>
public static bool ToBoolean(this float value)
{
return value != 0.0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static double LerpInternal(double a, double b, double t)
{

View File

@ -131,6 +131,18 @@ namespace X10D.SingleExtensions
return (float)((double)value).Round(nearest);
}
/// <summary>
/// Converts the value of the current single-precision floating-point number to an equivalent Boolean value.
/// </summary>
/// <param name="value">The value to convert.</param>
/// <returns>
/// <see langword="true" /> if <paramref name="value" /> is not zero, or <see langword="false" /> otherwise.
/// </returns>
public static bool ToBoolean(this float value)
{
return value != 0.0f;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static float LerpInternal(float a, float b, float t)
{