Author Topic: Problem with pow  (Read 2625 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
Problem with pow
« on: February 21, 2020, 01:13:49 AM »

The following code:

Code: [Select]
DOUBLE d = -2.5654885563273315
print pow(d, 2)

In 32bit outputs  6.581731532646495
In 64bit outputs  -6.5817313194274902

The following does not compile:
Code: [Select]
pow(-2.5654885563273315, 2)
Code: [Select]
ERROR: ERROR: unexpected comma in array index
WORD: -

Aurel

  • Guest
Re: Problem with pow
« Reply #1 on: February 21, 2020, 02:35:26 AM »
Hi Brian
for me work this:

print -2.5654885563273315 ^ 2

but for pow() o2 say - unindentified instruction !

Aurel

  • Guest
Re: Problem with pow
« Reply #2 on: February 21, 2020, 04:10:44 AM »
Hi
here is a quick solution  :D

Code: [Select]
'simple power func
function power(double num,int exponent) as double
double res
res = num ^ exponent
return res
end function

'test
print power(-2.5654885563273315,2)

Brian Alvarez

  • Guest
Re: Problem with pow
« Reply #3 on: February 21, 2020, 01:23:25 PM »
Nice! It works. WHat version are you using Aurel? SQR() is also giving me trouble.

Brian Alvarez

  • Guest
Re: Problem with pow
« Reply #4 on: February 21, 2020, 03:24:59 PM »
made my own.

Code: [Select]
    MACRO SQR extended(r, v)
        r = (v) ^ 0.5
    END MACRO

Charles Pegge

  • Guest
Re: Problem with pow
« Reply #5 on: February 22, 2020, 03:23:24 AM »

pow (and mod) can also be used as operators, without the prolems you report, Brian. Iwill need to investigate further...

What is the problem with sqr ?

Brian Alvarez

  • Guest
Re: Problem with pow
« Reply #6 on: February 22, 2020, 01:07:52 PM »

the problem is that in 64bit gives a different result than in 32bit.

Charles Pegge

  • Guest
Re: Problem with pow
« Reply #7 on: February 22, 2020, 02:05:18 PM »
Deleting all the deff blocks in RTL63.inc should clear the pow sign problem

sqrt should be okay. it uses the fsqrt instruction and only depends on the precision of the parameter pssed to it.
« Last Edit: February 22, 2020, 08:54:16 PM by Charles Pegge »

Aurel

  • Guest
Re: Problem with pow
« Reply #8 on: February 22, 2020, 11:27:13 PM »
Quote
WHat version are you using Aurel?

I use 0.2.8. 32bit

Brian Alvarez

  • Guest
Re: Problem with pow
« Reply #9 on: February 23, 2020, 02:38:21 PM »
Where did you get it from? I have 0.2.6 and i cant find any newer....

jack

  • Guest
Re: Problem with pow
« Reply #10 on: February 23, 2020, 07:07:49 PM »
hello Brian
from Charles Pegge's signature address get OxygenBasicProgress.zip

Arnold

  • Guest
Re: Problem with pow
« Reply #11 on: February 24, 2020, 12:24:04 AM »
Hi Brian,

in Github at the moment there is OxygenBasicProgress.zip, OxygenProgress.zip, latest commit 5 months ago. Perhaps you applied OxygenBasic.zip or Oxygen.zip, latest commit 7 months ago? I assume Charles will provide a more recent version anyway in the near future after resolving some of the requests.

Aurel

  • Guest
Re: Problem with pow
« Reply #12 on: February 24, 2020, 09:24:34 AM »
Yes there is on github..
I just look into Oxygen Basic page and found topic GAMES..
i don't know that even exist ..there are games of our old friend Peter Wirbelauer
( i miss that guy ,,,)
and download pac3D...well really nice game ...uffff
i must made one too...but first i must re-learn few things again  ::)

Brian Alvarez

  • Guest
Re: Problem with pow
« Reply #13 on: February 28, 2020, 08:55:55 PM »
I started having issues after i modified my MOD function. I tried:

Code: [Select]
%def ¤MOD mod
but was giving #qNaN with some parameters... i had to roll back to:

Code: [Select]
MACRO ¤MOD quad(r, v, e)
    r = mod(v, e)
END MACRO



Charles Pegge

  • Guest
Re: Problem with pow
« Reply #14 on: February 29, 2020, 07:14:06 AM »
I fixed the65bit sign prolem by removing the deff blocks from RTL64.inc.

These should work:

Code: [Select]
$filename "o.exe"
'uses RTL64
double p = pow(-2.5,2)
print 0 + pow(-2.5,2)
print "" + pow(-2.5,2)
print (pow(-2.5,2))
print -2.5 pow 2
print -2.5 ^ 2

0.2.9 coming soon..