Fix a bug when evaluating -0.5^3.
Use code which has been up to now only applied with LT compatibility.
This commit is contained in:
parent
afd4eb64ed
commit
b9221a07a3
|
|
@ -69,24 +69,21 @@ double
|
|||
PTpower(double arg1, double arg2)
|
||||
{
|
||||
double res;
|
||||
if (newcompat.lt) {
|
||||
if (arg1 == 0)
|
||||
|
||||
if (arg1 == 0)
|
||||
res = 0;
|
||||
else if(arg1 > 0)
|
||||
res = pow(arg1, arg2);
|
||||
else {
|
||||
/* If arg2 is quasi an integer, round it to have pow not fail
|
||||
when arg1 is negative. Takes into account the double
|
||||
representation which sometimes differs in the last digit(s). */
|
||||
if (AlmostEqualUlps(nearbyint(arg2), arg2, 10))
|
||||
res = pow(arg1, round(arg2));
|
||||
else
|
||||
/* As per LTSPICE specification for ** */
|
||||
res = 0;
|
||||
else if(arg1 > 0)
|
||||
res = pow(arg1, arg2);
|
||||
else {
|
||||
/* If arg2 is quasi an integer, round it to have pow not fail
|
||||
when arg1 is negative. Takes into account the double
|
||||
representation which sometimes differs in the last digit(s). */
|
||||
if (AlmostEqualUlps(nearbyint(arg2), arg2, 10))
|
||||
res = pow(arg1, round(arg2));
|
||||
else
|
||||
/* As per LTSPICE specification for ** */
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
res = pow(fabs(arg1), arg2);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +103,7 @@ PTpowerH(double arg1, double arg2)
|
|||
res = pow(arg1, arg2);
|
||||
}
|
||||
}
|
||||
else if (newcompat.lt) {
|
||||
else {
|
||||
if (arg1 >= 0)
|
||||
res = pow(arg1, arg2);
|
||||
else {
|
||||
|
|
@ -120,8 +117,6 @@ PTpowerH(double arg1, double arg2)
|
|||
res = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
res = pow(fabs(arg1), arg2);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue