Does anyone know why NetRexx (like Classic Rexx) doesn't allow fractional exponents?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Does anyone know why NetRexx (like Classic Rexx) doesn't allow fractional exponents?

Ramesh Gopal
Hi,

I do a lot of financial number crunching, and occasionally need a simple script to compute CAGRs (compound average growth rates).

The CAGR formula requires a fractional exponent to be evaluated, and I was surprised to learn that NetRexx doesn't support fractional exponents, just like its daddy Classic Rexx.

The appeal of NetRexx for me is better portability, performance and the ability to leverage so much in the rich JVM ecosystem. But the lack of a simple fractional exponent operation is a little annoying.

Anybody know why this is, and more importantly, what the most practical workaround?

Thanks.

Regards,
Ramesh


_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know why NetRexx (like Classic Rexx) doesn't allow fractional exponents?

Mike Cowlishaw

 
Anybody know why this is, and more importantly, what the most practical workaround? 
Arbitrary fractional exponents were not defined for Rexx or NetRexx because all the arithmetic operators are correctly rounded, and at the time Rexx and NetRexx were written no algorithm for a correctly rounded power operator was known.  Recently it has been proven it is possible to correctly round the operation but no upper bound on execution time has been proven.
 
Hence I'd still say that it's best to use a function which can then be defined as 'usually correctly rounded' and improve it later perhaps.
 
Since you cannot guarantee an exact/precise result in this case you may as well convert to doubles and use Java's Math.pow method.
 
(If the fractional part is only 1 or 2 digits always I think there's a workaround where you multiply it by (say) 100 to make it an integer, raise to the integer power and then take the 100th root.  Or something like that ... it's a long time since I looked at this.)
 
 
Mike

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know why NetRexx (like Classic Rexx) doesn't allow fractional exponents?

Mike Cowlishaw
In reply to this post by Ramesh Gopal
PS if you really want a decimal power function, one approach would be to port my decNumberPower function to NetRexx (it's currently in C).  That's quite tricky, however.
 
 
Mike 

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Does anyone know why NetRexx (like Classic Rexx) doesn't allow fractional exponents?

Ramesh Gopal
Thanks, Mike, for both the historical perspective and the 3 possible workarounds.

Since a mostly correct result is what I seek, I will use Java's Math.pow method.

Thanks and regards,
Ramesh


On Fri, Dec 1, 2017 at 7:01 PM, Mike Cowlishaw <[hidden email]> wrote:
PS if you really want a decimal power function, one approach would be to port my decNumberPower function to NetRexx (it's currently in C).  That's quite tricky, however.
 
 
Mike 

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/




_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/