|
|
@@ -9,7 +9,14 @@ public static class HexConverter
|
|
|
{
|
|
|
var sign = 1;
|
|
|
text = text.Trim();
|
|
|
- if (text[0] == '-')
|
|
|
+ var first = text[0];
|
|
|
+ if (first == '+')
|
|
|
+ {
|
|
|
+ // Remove the "+0x"
|
|
|
+ sign = 1;
|
|
|
+ text = text[3..];
|
|
|
+ }
|
|
|
+ else if (first == '-')
|
|
|
{
|
|
|
// Remove the "-0x"
|
|
|
sign = -1;
|
|
|
@@ -34,11 +41,28 @@ public static class HexConverter
|
|
|
return sign * (double)BigInteger.Parse(buffer.AsSpan()[..(text.Length + 1)], NumberStyles.AllowHexSpecifier);
|
|
|
}
|
|
|
|
|
|
- var intPart = dotIndex == -1 ? [] : text[..dotIndex];
|
|
|
- var decimalPart = expIndex == -1
|
|
|
- ? text.Slice(dotIndex + 1)
|
|
|
- : text.Slice(dotIndex + 1, expIndex - dotIndex - 1);
|
|
|
- var expPart = expIndex == -1 ? [] : text[(expIndex + 1)..];
|
|
|
+ ReadOnlySpan<char> intPart;
|
|
|
+ ReadOnlySpan<char> decimalPart;
|
|
|
+ ReadOnlySpan<char> expPart;
|
|
|
+
|
|
|
+ if (dotIndex == -1)
|
|
|
+ {
|
|
|
+ intPart = text[..expIndex];
|
|
|
+ decimalPart = [];
|
|
|
+ expPart = text[(expIndex + 1)..];
|
|
|
+ }
|
|
|
+ else if (expIndex == -1)
|
|
|
+ {
|
|
|
+ intPart = text[..dotIndex];
|
|
|
+ decimalPart = text[(dotIndex + 1)..];
|
|
|
+ expPart = [];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ intPart = text[..dotIndex];
|
|
|
+ decimalPart = text.Slice(dotIndex + 1, expIndex - dotIndex - 1);
|
|
|
+ expPart = text[(expIndex + 1)..];
|
|
|
+ }
|
|
|
|
|
|
var value = intPart.Length == 0
|
|
|
? 0
|