Handle integer inputs for Fraction ctor without try/catch

This commit is contained in:
N00MKRAD
2024-08-21 13:27:01 +02:00
parent d0a7c0aee4
commit b5f2fea32d

View File

@@ -53,7 +53,16 @@ namespace Flowframes.Data
try try
{ {
string[] numbers = text.Split('/'); string[] numbers = text.Split('/');
Numerator = numbers[0].GetInt();
// Check if split is only 1 items (probably integer number)
if (numbers.Length == 1)
{
Numerator = numbers[0].GetFloat().RoundToInt();
Denominator = 1;
return;
}
Numerator = numbers[0].GetFloat().RoundToInt();
Denominator = numbers[1].GetInt(); Denominator = numbers[1].GetInt();
} }
catch catch
@@ -66,7 +75,7 @@ namespace Flowframes.Data
catch catch
{ {
Numerator = 0; Numerator = 0;
Denominator = 0; Denominator = 1;
} }
} }