Browse Source

Fix: overflow

AnnulusGames 1 year ago
parent
commit
b07789081f
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/Lua/Internal/HexConverter.cs

+ 3 - 2
src/Lua/Internal/HexConverter.cs

@@ -1,4 +1,5 @@
 using System.Globalization;
 using System.Globalization;
+using System.Numerics;
 
 
 namespace Lua.Internal;
 namespace Lua.Internal;
 
 
@@ -24,7 +25,7 @@ public static class HexConverter
 
 
         if (dotIndex == -1 && expIndex == -1)
         if (dotIndex == -1 && expIndex == -1)
         {
         {
-            return long.Parse(text, NumberStyles.AllowHexSpecifier);
+            return (double)BigInteger.Parse(text, NumberStyles.HexNumber);
         }
         }
 
 
         var intPart = dotIndex == -1 ? [] : text[..dotIndex];
         var intPart = dotIndex == -1 ? [] : text[..dotIndex];
@@ -35,7 +36,7 @@ public static class HexConverter
 
 
         var value = intPart.Length == 0
         var value = intPart.Length == 0
             ? 0
             ? 0
-            : long.Parse(intPart, NumberStyles.AllowHexSpecifier);
+            : long.Parse(intPart, NumberStyles.HexNumber);
 
 
         var decimalValue = 0.0;
         var decimalValue = 0.0;
         for (int i = 0; i < decimalPart.Length; i++)
         for (int i = 0; i < decimalPart.Length; i++)