Problem when using variable
echo ""| awk '{
x=-0.35
print x^1.35
print -0.35^1.35
}'
Result
+nan
-0.242377
Using GNU awk
The output is correct.
The power operator ^
has higher precedence than the negation operator. Therefore, x^1.35
is (-0.35)^1.35
(a negative number to a non-integer power is a complex number, interpreted as a -nan
), but -0.35^1.35
is -(0.35^1.35)
, a negated positive power of a positive number.