Author Topic: pow(-2,2)=-4  (Read 8685 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
Re: pow(-2,2)=-4
« Reply #15 on: October 22, 2013, 10:42:28 AM »
Code: [Select]
FOR x = -2 to -4 STEP -1
  FOR y = .1 to .5 STEP .1
    PRINT "x = ",x," y = ",FORMAT("%g",y)," -  ",FORMAT("%3.6f",x^y),"\n"
  NEXT y
NEXT x

jrs@laptop:~/sb/sb22/test$ scriba testpow.sb
x = -2 y = 0.1 -  0.000000
x = -2 y = 0.2 -  -1.148698
x = -2 y = 0.3 -  0.000000
x = -2 y = 0.4 -  0.000000
x = -2 y = 0.5 -  0.000000
x = -3 y = 0.1 -  0.000000
x = -3 y = 0.2 -  -1.245731
x = -3 y = 0.3 -  0.000000
x = -3 y = 0.4 -  0.000000
x = -3 y = 0.5 -  0.000000
x = -4 y = 0.1 -  0.000000
x = -4 y = 0.2 -  -1.319508
x = -4 y = 0.3 -  0.000000
x = -4 y = 0.4 -  0.000000
x = -4 y = 0.5 -  0.000000
jrs@laptop:~/sb/sb22/test$

@Charles - Is SB spitting out garbage or is there some explanation for these results? (at least SB isn't spitting NAN's)
« Last Edit: October 22, 2013, 02:06:41 PM by John »

Peter

  • Guest
Re: pow(-2,2)=-4
« Reply #16 on: October 22, 2013, 10:59:59 AM »
Is a Null-Complexe  :D

Aurel

  • Guest
Re: pow(-2,2)=-4
« Reply #17 on: October 22, 2013, 11:48:15 AM »
No ...
less than zero complex... ;D

Code: [Select]
'po po po power....r..rr..

sub power(sys a,ex) as sys
sys res
if a < 0
res = -(a ^ ex)
else
res = a ^ ex
end if
return res
end sub

sys is
is = power(-2,2)

print str(is)