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

0 Members and 1 Guest are viewing this topic.

#### John

• Hero Member
• Posts: 3158
##### 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 yNEXT 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

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

#### Aurel

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

Code: [Select]
`'po po po power....r..rr..sub power(sys a,ex) as syssys resif a < 0 res = -(a ^ ex)else res = a ^ exend ifreturn resend subsys isis = power(-2,2)print str(is) `