To find the nearest integer, use nearbyint(). trunc() has delivered

only one-sided answers.
This commit is contained in:
Holger Vogt 2022-11-11 13:21:21 +01:00
parent 47f2b7c6af
commit d77e36dc1b
1 changed files with 1 additions and 1 deletions

View File

@ -78,7 +78,7 @@ PTpower(double arg1, double arg2)
/* If arg2 is quasi an integer, round it to have pow not fail /* If arg2 is quasi an integer, round it to have pow not fail
when arg1 is negative. Takes into account the double when arg1 is negative. Takes into account the double
representation which sometimes differs in the last digit(s). */ representation which sometimes differs in the last digit(s). */
if (AlmostEqualUlps(trunc(arg2), arg2, 10)) if (AlmostEqualUlps(nearbyint(arg2), arg2, 10))
res = pow(arg1, round(arg2)); res = pow(arg1, round(arg2));
else else
/* As per LTSPICE specification for ** */ /* As per LTSPICE specification for ** */