Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

BigDecimal to power of BigDecimal

Thread view: 
czarnysfetr@gmail.com - 05 Feb 2007 12:18 GMT
Hi,

I have a problem with calculating expression, in which I have to use

BigDecimal1 ^ BigDecimal2

BigDecimal.pow() isn't suitable - as far as I know, it requires int as
an parameter, and both my numbers are BigDecimals.

Does anyone know how to handle it?

sfetr
Eric Sosman - 05 Feb 2007 13:54 GMT
> Hi,
>
[quoted text clipped - 6 lines]
>
> Does anyone know how to handle it?

    bd1.pow(bd2.intValue()) looks like a good starting point.
If bd2 has a fractional part, you'll need to work harder --
perhaps Math.pow(bd1.doubleValue(), bd2.doubleValue()) would
be of use, followed by conversion from double to BigDecimal.

    Seems like a strange thing to want to do, though.  I hope
you've got lots of memory ...

Signature

Eric Sosman
esosman@acm-dot-org.invalid

Patricia Shanahan - 05 Feb 2007 14:32 GMT
>> Hi,
>>
[quoted text clipped - 14 lines]
>     Seems like a strange thing to want to do, though.  I hope
> you've got lots of memory ...

Even if the double approach does not give enough accuracy, it might be a
good starting point for an iterative improvement algorithm such as
Newton-Raphson.

However, it definitely needs to be dome carefully, with attention to
trade-offs between accuracy and memory.

Patricia
czarnysfetr@gmail.com - 05 Feb 2007 14:49 GMT
Thanks a lot, problem vanished :-)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.