Fixed a problem with r64 parsing
This commit is contained in:
parent
3a04aab4fd
commit
4f199ee1c6
|
@ -1885,12 +1885,16 @@ ValidateAndParseFloat(gs_const_string String)
|
||||||
|
|
||||||
if (StringIsValid)
|
if (StringIsValid)
|
||||||
{
|
{
|
||||||
u64 DecimalIndex = FindFirst(String, '.');
|
s64 DecimalIndex = FindFirst(String, '.');
|
||||||
u64 TempParsedLength = 0;
|
u64 TempParsedLength = 0;
|
||||||
u64 PlacesAfterPoint = 0;
|
u64 PlacesAfterPoint = 0;
|
||||||
|
|
||||||
gs_const_string IntegerString = GetStringBefore(String, DecimalIndex);
|
gs_const_string IntegerString = GetStringBefore(String, DecimalIndex);
|
||||||
gs_const_string DecimalString = GetStringAfter(String, DecimalIndex + 1);
|
gs_const_string DecimalString = {};
|
||||||
|
if (DecimalIndex >= 0)
|
||||||
|
{
|
||||||
|
DecimalString = GetStringAfter(String, DecimalIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
r32 Polarity = 1;
|
r32 Polarity = 1;
|
||||||
if (IntegerString.Str[0] == '-')
|
if (IntegerString.Str[0] == '-')
|
||||||
|
@ -1910,7 +1914,7 @@ ValidateAndParseFloat(gs_const_string String)
|
||||||
}
|
}
|
||||||
|
|
||||||
Result.ParsedLength = TempParsedLength + PlacesAfterPoint;
|
Result.ParsedLength = TempParsedLength + PlacesAfterPoint;
|
||||||
if (DecimalIndex < String.Length) { Result.ParsedLength += 1; }
|
if (DecimalIndex < (s64)String.Length) { Result.ParsedLength += 1; }
|
||||||
|
|
||||||
Result.Success = true;
|
Result.Success = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,14 +76,16 @@ int main (int ArgCount, char** Args)
|
||||||
TestResult(ParseUInt(ConstString("532")) == 532);
|
TestResult(ParseUInt(ConstString("532")) == 532);
|
||||||
TestResult(ParseInt(ConstString("-1234567890")) == -1234567890);
|
TestResult(ParseInt(ConstString("-1234567890")) == -1234567890);
|
||||||
TestResult(ParseFloat(ConstString("-12345.6789")) == -12345.6789);
|
TestResult(ParseFloat(ConstString("-12345.6789")) == -12345.6789);
|
||||||
|
TestResult(ParseFloat(ConstString("-1")) == -1);
|
||||||
|
TestResult(ParseFloat(ConstString("-.035")) == -.035);
|
||||||
|
|
||||||
TestString.Length = 0;
|
TestString.Length = 0;
|
||||||
U64ToASCII(&TestString, 53298, 10);
|
U64ToASCII(&TestString, 53298, 10);
|
||||||
TestResult(StringTest(TestString.ConstString, ConstString("53298")));
|
TestResult(StringTest(TestString.ConstString, ConstString("53298")));
|
||||||
|
|
||||||
TestString.Length = 0;
|
TestString.Length = 0;
|
||||||
R64ToASCII(&TestString, 145732.321, 2);
|
R64ToASCII(&TestString, -145732.321, 2);
|
||||||
TestResult(StringTest(TestString.ConstString, ConstString("145732.32")));
|
TestResult(StringTest(TestString.ConstString, ConstString("-145732.32")));
|
||||||
}
|
}
|
||||||
|
|
||||||
Test("gs_path.h")
|
Test("gs_path.h")
|
||||||
|
|
Loading…
Reference in New Issue