From 9c51e72cc215d43509c0635d254ac51ef081561a Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Sat, 20 Jun 2020 21:26:29 +0200 Subject: [PATCH] CS: Fix representation of Infinity and NaN --- Il2CppInspector.Common/Reflection/Extensions.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector.Common/Reflection/Extensions.cs b/Il2CppInspector.Common/Reflection/Extensions.cs index 54dbab1..cccfb3c 100644 --- a/Il2CppInspector.Common/Reflection/Extensions.cs +++ b/Il2CppInspector.Common/Reflection/Extensions.cs @@ -88,7 +88,19 @@ namespace Il2CppInspector.Reflection if (value is bool) return (bool) value ? "true" : "false"; if (value is float) - return value + "f"; + return value switch { + float.PositiveInfinity => "1F / 0F", + float.NegativeInfinity => "-1F / 0F", + float.NaN => "0F / 0F", + _ => value + "f" + }; + if (value is double) + return value switch { + double.PositiveInfinity => "1D / 0D", + double.NegativeInfinity => "-1D / 0D", + double.NaN => "0D / 0D", + _ => value.ToString() + }; if (value is string str) { return $"\"{str.ToEscapedString()}\""; }