Computing an appropriate division scale for pow with negative arguments?

  private static BigDecimal pow(BigDecimal bd, int n) {
    return n < 0 ? BigDecimal.ONE.divide(bd.pow(-n), _ARBITRARY_NUMBER_ , BigDecimal.ROUND_HALF_UP) : bd.pow(n);
  }Rather than plugging in an arbitrarily large number for the scale in the division operation, I would like to try to set the value appropriately. I tried simple formula that basically mulitiplied bd * n / 10, which worked nicely for some values, but gave overly large values for others.
Based on the data that I expect to process I think I could set it to 3000, but I would prefer not to take the risk, and it's just plain stupid to make all calls to the function pay the penalty.
Is there a algorithm that could approximate the value of what the final answer will be so I can plug an appropriate value into the scale?

Is there a algorithm that could approximate the value of what the final answer will be so I can
plug an appropriate value into the scale? You don't need a scale for the pow operation, so first do BigDecimal recip = bd.pow(-n)Now the final answer is 1 / recip, so the scale is roughly -log10(recip). Google BigDecimal logarithm and you'll find a few open source libraries which can do that stage. (In fact IIRC you'll find a library which does arbitrary powers of BigDecimals).

Similar Messages

  • How to scan my computer and external hard drives for pictures with out importing duplicates.

    how do i scan my computer and external hard drives for pictures with out importing duplicates.

    iPhoto doesn't scan anywhere. It imports files offered to it. If it spots a duplicate it will warn you.

  • HT1541 computer authorisations 5computers are authorised for use with this apple id

    you may only deauthorize all computers once per year you must wait until 30 july2012 before you may deauthorize all your computers again if you are having problems deauthorizing computers please contact apple customer support by visiting

    If you've already used the 'deauthorise all' within the past 12 months then have you tried contacting iTunes support : http://www.apple.com/support/itunes/ ?

  • Relative Time Scale for X-Axis when creating a Line Graph in CS3?

    Is there a way to get the APPROPRIATE RELATIVE scale for the X-Axis (Category) when you're using dates?
    Example:
    If this is my data set:
                        Group A          Group B
    01/03/99                1                5
    01/04/99                11                3
    01/05/99                6                12
    11/27/07                63                54
    If I plot this in Xcel, by default, each date (x-axis) will be spaced the same distance apart. However, there is a checkbox to "time-scale" the X-Axis which will place the dates relative to one another. In other words, if we're talking about a bar graph, the first three bars would be close together on the left side of the chart, and the 4th bar would be waaaaaay on the right side of the graph.
    So, below, if 'x' is a bar, I keep getting this in CS3:
    x     x     x     x
    I want to get this:
    x x x             x
    Get it?

    Is there a way to get the APPROPRIATE RELATIVE scale for the X-Axis (Category) when you're using dates?
    Example:
    If this is my data set:
                        Group A          Group B
    01/03/99                1                5
    01/04/99                11                3
    01/05/99                6                12
    11/27/07                63                54
    If I plot this in Xcel, by default, each date (x-axis) will be spaced the same distance apart. However, there is a checkbox to "time-scale" the X-Axis which will place the dates relative to one another. In other words, if we're talking about a bar graph, the first three bars would be close together on the left side of the chart, and the 4th bar would be waaaaaay on the right side of the graph.
    So, below, if 'x' is a bar, I keep getting this in CS3:
    x     x     x     x
    I want to get this:
    x x x             x
    Get it?

  • HT5815 im searching a for a update there makes it possible for mac computer with OS X To play games there aren't Supported for power pc, Like Warcraft 3, Diablo 2 and those kind of old games there worked on the previous versions of the OS

    im searching a for a update there makes it possible for mac computer with OS X To play games there aren't Supported for power pc, Like Warcraft 3, Diablo 2 and those kind of old games there worked on the previous versions of the OS

    Here is a thread for you: Is there any possible way to run PPC...: Apple Support Communities

  • Replace quotient and Remainder with Scale by power 2

    I want to replace quotient and Remainder function with Scale by power 2 to reduce resource usage on FPGA.
    Here is my problem, I want to achive the same result, but no sure if the code will allow me to input the value I need, i also am not sure what that value should be?
    Attachments:
    quotientProblem.png ‏37 KB

    Florian.Ludwig wrote:
    The problem is I don't know what's expensive in RT.
    The OP is asking about FPGA, not RT.
    RT is fine with the Quotient & Remainder.  It'll take a few clock cycles of your processor, but that is nothing in the rates for an RT system.
    An FPGA is a different beast since you need to look at how much of your FPGA hardware you are using up.  Bit shifting (which is what the power of 2 actually does) is dirt cheap in an FPGA.  But divisions are really expensive to do.  But since you are dealing with powers of 10, you are kind of stuck.  Hardware (FPGA in this case) works best when dealing with binary (ie powers of 2).
    So what device is this one?  How fast do you need these outputs?  It might make sense to pass some of the data up to the RT system and then the RT can pass the results back down to the FPGA for actual output.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • My iPad won't charge after plugging into my computer and after holding down the power and home button at same time for 10 seconds- Can anybody help? Has IOS7.0 but the most up-to-date version

    My iPad won't charge after plugging into my computer and after holding down the power and home button at same time for 10 seconds… Can anybody help? Has IOS7.0 but not the most up-to-date version

    It's just the battery sign - nothing else. I've tried to reboot by holding down both power and home key for 10+ seconds, waiting for the apple logo - but nothing happens. It's plugged into the imac at the moment. I tried to recharge it overnight using the normal charger - but no luck. It went dead during a Skype call with a friend - even though it was powered into the mains - albeit at a low battery level at the time

  • I have a problem with the indicator for power on the side of my HP DV6-1341el.

    I have a problem with the indicator for power on the side of my HP DV6-1341el. Insert the adapter's power jack on the notebook in front of the LED battery charging works, windows detects that the battery is charged, but if I use the diagnostic programs, they tell me they found that the computer is running on battery power and not AC mode.
    Where is the problem?
    I have also made the maneuver for the recognition by the operating system of the battery and does not seem to be there the problem.
    If I use the laptop without battery in AC mode happens that led to the side of the notebook blinks twice, three times and then goes off when I put the power jack.

    Go into the Device Manager. Expand the battery device, select the ACPI-Compliant Battery Control Method device, right-click it and select uninstall. After you have done that, right-click any device in the Device Manager and select scan for hardware changes. Your operating system will reinstall the  ACPI-Compliant Battery Control Method device. 
    Post your results whether they are negative or positive to keep us posted.
    ****Please click on Accept As Solution if a suggestion solves your problem. It helps others facing the same problem to find a solution easily****
    2015 Microsoft MVP - Windows Experience Consumer

  • I have a power pc (g5) computer that I will soon be replacing with a current i5 or i7 mini. How do I transfer the Time Machine files from the internal hard drive on the G5 to an external drive that I will later use with the Mini?

    I have a Power PC G5 computer that I will soon be replacing with a current i5 or i7 Mini. How do I transfer the Time Machine files from the internal hard drive on the G5 to an external drive that I will later use with the Mini?

    Hi, likely the easiest is to just poll the drive & get something like this...
    Get MacScan...
    http://www.apple.com/downloads/macosx/networking_security/macscan.html
    http://eshop.macsales.com/item/NewerTech/U3NVSPATA/
    But if you have a good external drive already, just clone it.
    Get carbon copy cloner to make an exact copy of your old HD to the New one...
    http://www.bombich.com/software/ccc.html
    Or SuperDuper...
    http://www.shirt-pocket.com/SuperDuper/

  • Old computer I had is OSX Snow Leopard with Entourage. New one is OSX Mavericks. Using Mail where are my addresses and old address book. Transferred old computer backup by Time Machine and other things work? Can't see a symbol for address book.

    Old computer I had is OSX Snow Leopard with Entourage. New one is OSX Mavericks. Using Mail where are my addresses and old address book. Transferred old computer backup by Time Machine and other things work? Can;t see a symbol for address book.

    Where are addresses kept on MAIL?  I don;t like the new format at all. Frances
    Begin forwarded message:
    From: Frances Topping <[email protected]>
    Subject: Re: - Old computer I had is OSX Snow Leopard with Entourage. New one is OSX Mavericks. Using Mail where are my addresses and old address book. Transferred old computer backup by Time Machine and other things work? Can't see a symbol for address book.
    Date: August 25, 2014 at 9:46:01 AM EDT
    To: discussions-replies <[email protected]>
    Old Entourage is POP and new Mavericks MAIL  is IMAP I believe. I don;t know how to export in the forms you mention. Frances

  • I changed my apple id and password online, next time i turned on my computer icloud pops up asking for a password with my old apple id.  i enter my password and it doesnt work, how do i change my iCloud id to my updated apple id?

    I changed my apple id and password online.  The next time I turned on my computer, iCloud popped up asking for a password, but displaying my old apple id.  I tried signing in, but I think because it is my old apple id listed it doesnt let me.  Anyone have any idea how I can update the iCloud apple id and password to reflect that of my apple id?

    If the old ID is yours, and if your current ID was created by editing the details of this old ID (rather than being an entirely new ID), go to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Click edit next to the primary email account, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iDevice, even though it prompts you for the password for your old account ID. Then save any photo stream photos that you wish to keep to your camera roll.  When finished go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • HT1386 I can't synchronise phone 5s with mac book pro. mac message me : the i phone could not be synchronised because this computer is no longer authorised for purchased items that are on this i phone. then go and authorised mac but keep send me the same

    I can't synchronise phone 5s with i tunes . mac message me : the i phone could not be synchronised because this computer is no longer authorised for purchased items that are on this i phone. then go and authorised mac but keep send me the same message.

    Hi john,
    Follow the troubleshooting steps in this article:
    http://support.apple.com/kb/ts1389
    Cheers,
    GB

  • I have a problem with my itunes. I cannot transfer apps from the itunes to my iphone 4s. Any time I try to snyc itunes tells me "The iphone could not be synced because this computer is no longer authorized for purchased items that are on this iphone. HELP

    I have a problem with my itunes. I cannot transfer apps from the itunes to my iphone 4s. Any time I try to snyc itunes tells me "The iphone could not be synced because this computer is no longer authorized for purchased items that are on this iphone. To authorize this computer for items purchased from the itunes store, choose, Store > Authorize This Computer. But anytime I authorize it tells me you have authorized including this computer 2 out 5 computers. And if I try again the same story over and over again. But I have many apps on my itunes which I want to transfer. Please someone help me.

    Well Authorize the Computer...........

  • I don't know what is going on with the White Balance (WB) and LR.  I had no problem before but recently LR started to change the  WB as  it is importing photos.  I checked the color scale for my photos and LR and both are with sRGB.  Now instead of LR cha

    I don't know what is going on with the White Balance (WB) and LR.  I had no problem before but recently LR started to change the  WB as  it is importing photos.  I checked the color scale for my photos and LR and both are with sRGB.  Now instead of LR changing the WB it is giving me a second copy with a new WB.  Your advise is very much needed and appreciated.  Thank you.

    Can you show us a screen capture of this 2nd copy with a new WB in your Lightroom grid? Thanks
    Are these second copy photos by any chance photos that had been previously imported?

  • When I click on itunes, it tells me that thesoftware required for communicating with ipods and mobil phones was not installed properly. I have not changed anything on my computer so I'm not sure what I should do? Help

    Help, When I click on itunes on my computer it tells me that the software required for communicating with ipods and mobil phone was not installed properly. I havent' changed anything. Does anyone know what I should do? Thanks

    See the second box of Troubleshooting issues with iTunes for Windows updates.
    tt2

Maybe you are looking for

  • Mapping in a Business Process

    Hi, I have a business process. This process is calling one webservice first. To call the second one the result from the first webservice and the input for the whole business process is needed. How can I create a mapping for this or solve this problem

  • System Preferences Sharing Issue - computer is mis-named somehow

    Hello all, I have 2 MBP's and I connect to one often through screen sharing.   The machine i connect to now has the screen sharing name of an Airport Express that i set up with it.  It also has this name in web sharing as well.   Is there a way to ch

  • Program giving syntax error in Production client

    Hi Experts,             I have moved an object into testing client its working fine there,but when it was moved from testing to production client.             they are getting the error as "program ZSIOPCN contains syntax errors", when they are tryin

  • Adobe creative suite master collection

    I bought my son "Adode Cerative suite 6 Master collection" (academic version) Unfortunately – his laptop was stolen and had to install the second copy on his replacement. He had to take the second copy of CS6 off our main PC so he didn't go over the

  • Error running forms 10g with OC4J

    Hi everyone, I installed Oracle DB 10g and Developer Suite 10g (did not install Ap. Server) at the same machine (different homes), everything seemed to be OK, I use sqlplus with no problems, then I did this: 1) Created a table with just one field 2)