Fix broken complex number conversion cases
This commit is contained in:
parent
8c65243b1a
commit
c05bbf2627
@ -174,6 +174,9 @@ namespace System {
|
||||
// Split the input into real and imaginary parts
|
||||
string[] parts = input.Split(new[] { '+', '-' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
// If starts by - (fix for -1+3i, etc)
|
||||
double factor = input.StartsWith("-") ? -1 : 1;
|
||||
|
||||
if (input.Contains("+")) {
|
||||
real = double.Parse(parts[0], CultureInfo.InvariantCulture);
|
||||
imaginary = double.Parse(parts[1], CultureInfo.InvariantCulture);
|
||||
@ -186,6 +189,8 @@ namespace System {
|
||||
} else {
|
||||
imaginary = double.Parse(parts[0], CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
real *= factor;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user