|
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/ |
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.)
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
|
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.
decNumber is at: http://speleotrove.com/decimal/#decNumber
Mike
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
|
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:
_______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
| Free forum by Nabble | Edit this page |
