commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paul womack <>
Subject Re: [Math] BigDecimal to power
Date Thu, 27 Jan 2011 12:28:38 GMT
Andy Turner wrote:
> Hi,
> I've implemented code for calculating a BigDecimal raised to the power of another BigDecimal
and which returns the result rounded to a specified number of decimal places. It is in the
maths package of my Generic library and can be found via the following URL:
> There are no third party dependencies. I have not fully tested the code and already after
I released I found a bug which is only updated in subversion repository. Anyway in general
the methods work and should be generally useful. I looked for code to do this two years ago
and although I expect there are other implementations, I had no luck finding any and this
week I bit the bullet.

I was recently doing something unrelated in Excel and OOCalc.

Someone had pointed out that cube root can (under some circumstances) be a useful
transform for the x axis when plotting a graph.

It's similar to log(x) for positive x, but has (very!) different behaviour
for x < 1, and (very!) different behaviour for x < 0. In particular
the sign of the cube root is the same as the sign of x.

This applies for all odd numbered roots. Anyway.

I discovered that Excel is quite capable of evaluating power(x, 1/3) for negative x,
where oocalc isn't.

I assume that oocalc is using the "obvious" but flawed implementation of power(x, y)

invlog(log(x) *  y))

You might want to check your implementation under such data.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message