mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-22 23:58:48 +00:00
Fix incorrect return values for ComplexSqrt
This commit is contained in:
parent
b8dd5cc8bf
commit
8008a4a9ef
@ -19,6 +19,15 @@ public static class DoubleExtensions
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static Complex ComplexSqrt(this double value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case double.PositiveInfinity:
|
||||
case double.NegativeInfinity:
|
||||
return Complex.Infinity;
|
||||
case double.NaN:
|
||||
return Complex.NaN;
|
||||
}
|
||||
|
||||
double absoluteSqrt = Math.Abs(value).Sqrt();
|
||||
return new Complex(absoluteSqrt, value >= 0 ? 0 : 1);
|
||||
}
|
||||
|
@ -19,6 +19,15 @@ public static class SingleExtensions
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static Complex ComplexSqrt(this float value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case float.PositiveInfinity:
|
||||
case float.NegativeInfinity:
|
||||
return Complex.Infinity;
|
||||
case float.NaN:
|
||||
return Complex.NaN;
|
||||
}
|
||||
|
||||
float absoluteSqrt = MathF.Abs(value).Sqrt();
|
||||
return new Complex(absoluteSqrt, value >= 0 ? 0 : 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user