From 27a370cffed28503e25a81ff452305b528520a85 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 16 Mar 2021 15:02:41 +0000 Subject: [PATCH] Add float/double.ToBoolean --- X10D/src/DoubleExtensions/DoubleExtensions.cs | 12 ++++++++++++ X10D/src/SingleExtensions/SingleExtensions.cs | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/X10D/src/DoubleExtensions/DoubleExtensions.cs b/X10D/src/DoubleExtensions/DoubleExtensions.cs index d53537d..8605a86 100644 --- a/X10D/src/DoubleExtensions/DoubleExtensions.cs +++ b/X10D/src/DoubleExtensions/DoubleExtensions.cs @@ -130,6 +130,18 @@ namespace X10D.DoubleExtensions return Math.Round(value / nearest) * nearest; } + /// + /// Converts the value of the current double-precision floating-point number to an equivalent Boolean value. + /// + /// The value to convert. + /// + /// if is not zero, or otherwise. + /// + public static bool ToBoolean(this float value) + { + return value != 0.0; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static double LerpInternal(double a, double b, double t) { diff --git a/X10D/src/SingleExtensions/SingleExtensions.cs b/X10D/src/SingleExtensions/SingleExtensions.cs index fe91ef0..185a28e 100644 --- a/X10D/src/SingleExtensions/SingleExtensions.cs +++ b/X10D/src/SingleExtensions/SingleExtensions.cs @@ -131,6 +131,18 @@ namespace X10D.SingleExtensions return (float)((double)value).Round(nearest); } + /// + /// Converts the value of the current single-precision floating-point number to an equivalent Boolean value. + /// + /// The value to convert. + /// + /// if is not zero, or otherwise. + /// + public static bool ToBoolean(this float value) + { + return value != 0.0f; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static float LerpInternal(float a, float b, float t) {