From c5d2b46a671dd139b945cc8fa8896ab1111842d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Thu, 2 Aug 2018 10:51:20 +0100 Subject: [PATCH] Improve System.Single MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove workaround code (not required anymore as native code now handles this type and format properly Signed-off-by: José Simões --- source/System/Single.cs | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/source/System/Single.cs b/source/System/Single.cs index 75ea4502..2a71f92c 100644 --- a/source/System/Single.cs +++ b/source/System/Single.cs @@ -14,7 +14,10 @@ namespace System [Serializable] public struct Single { + // this field is required in the native end +#pragma warning disable 0649 internal float _value; +#pragma warning restore 0649 /// /// Represents the smallest possible value of Single. This field is constant. @@ -37,16 +40,7 @@ public struct Single /// The string representation of the value of this instance. public override String ToString() { - var str = ((Double)_value).ToString(); - switch (str) - { - case "Infinity": - case "-Infinity": - case "NaN": - return str; - default: - return Number.Format(_value, false, "G", NumberFormatInfo.CurrentInfo); - } + return Number.Format(_value, false, "G", NumberFormatInfo.CurrentInfo); } /// @@ -56,16 +50,7 @@ public override String ToString() /// The string representation of the value of this instance as specified by format. public String ToString(String format) { - var str = ((Double)_value).ToString(); - switch (str) - { - case "Infinity": - case "-Infinity": - case "NaN": - return str; - default: - return Number.Format(_value, false, format, NumberFormatInfo.CurrentInfo); - } + return Number.Format(_value, false, format, NumberFormatInfo.CurrentInfo); } } }