Double problem truncating

Hi !!
I've a function that works so:
public double calibrate ( int d )
double value = Math.pow( 2, -21 );
return ( d * value );
Suppose that d is 47614.
Function must return 0.02270412445068359375 but
output is 0.022704124450683594. Why ?
Can I control truncating and rounding ?
My target is that the function return 0.02270412445068359375
Can anyone help me?
Thanks.

And now you request a finders fee and a place in the
MySql hall of fame -:) Woohoo! My life's ambition achieved! ;)
No just kidding. I found the
same reference independenly using AltaVista, and
formulated my first reply without knowing about your
reply. But okay, I hereby acknowledge you as the
original finder of this link in this thread.Heh. No, I figured you hit it independently - I was mostly just amused at the coincidence.
Use Google - it's faster, and -you'll- get the finder's fee next time! ;)
Grant

Similar Messages

  • IE margin doubling problem

    I am working on a site. I have a floated horizontal list of items at the very top of the header. It looks fine in Firefox and Safari but in IE 8 it forces the last item on to a second line. I have read about the margin doubling problem with IE and I've tried all sorts of ways to keep this from happening but can't seem to figure it out.
    http://www.prospectrealty1.fatcow.com/index.html
    any help on how I can keep the floated list all on one line in IE will be very much appreciate.
    thanks!

    markf12 wrote
    The problem is with the line of text (address, phone, etc) at the very top of the header, not the nav. It looks fine in Firefox and Safari but not in IE. I believe it's because of the IE margin doubling that I have learned about. I've got the string of text/ bullet list so it fills the space with 20 px space on each end. When IE adds extra margin it forces the last item (email address) down onto a second line. 
    I'm thinking of replacing all but the email address with a jpg image. Leaving the email address as a link that can be clicked. I was hoping to find a fix for this IE problem so I could keep it all as text which is a better practice as I understand it.
    Oh ok I didnt see that because in Adobe Browser lab the text is showing all on one line in IE7, IE8 and IE9 so it would be difficult for me to diagnose.
    I can tell you though it has nothing to do with double margin bug as IE8 and IE9 corrected that. It was only present in IE7 maybe and certainly in IE6. However having said that the IE double margin bug only occurred when you had a floated element which had a margin applied to it in the same direction as the float, i.e. if you floated an element left and then attached a left margin to that element also the margin would double. The solution was to add display: inline; to the elements css selector BUT you have no left margin set on the <li> tag.
    It is most likely as Nancy points out an engine difference in the way IE browsers size the text. Does this occur if you use px instead of em? If not use px....I never use em myself as I've found it does cause issues ocassionally. Also its not good practice to fill a whole horizontal line with text information where you want its visual appearence maintained, very bad. Horizontal menus never work and lines of text never do either. The art of designing a webpage is allowing enough space so the text can 'grow' into in the case when a browser interprets the text size slightly differently. Obviously that's difficult if you are re-creating this webpage build for some designer who has little knowledge of good web design practices.
    In cases where a client is absolutely definitive that they want too many links in a horizontal menu or a line of text, which must remain on one line, I would have no hestitaion about using an image. Just give the image an 'alt' and if the image is surrounded by an anchor tag give that a 'title' tag. That will keep your page 'user' friendly for those who have a disabilities.

  • GreenSock Doubling Problem (Bug?)

    I've run into an issue where if I set the visibility to an object that is being tweened to 1, GS creates a second instance of the object.
    In the attached file, click the 'btn' and notice that a 2nd row of envelopes is created and they are not blitted like the original instance.
    Bug or operator error?
    Thanks.
    www.thepixelfarm.com/tmp/GS_doublingProb01.zip

    This is NOT a bug. See the answer in the GreenSock forums:
    http://forums.greensock.com/topic/6163-greensock-doubling-problem-bug/

  • Double problem in string conversion

    I'm working on a web application. (this questions is not we related.. just giving some background to the problem) I populate a number of fields in a bean back in my business logic as Decimals. Then going up a level I do all the data manipulate I need to for display purposes and store the values as a String inside my bean. Then I pass that bean on to my jsp and it displays my values....
    Now the problem I just realized I have is that in some cases the decimal values are larger then 8 digits in length. So when I convert to a string by saying decimalVariable+""
    I end up with an exponential value.
    There are several solutions to this... but the problem is that I have thousands of places this is being done... so instead of going in and changing every decimal to a bigDecimal or going in and changing the way I convert to a string in each place, I wanted to know if I could change the toString method for Decimal.. and how to go about doing that...

    As far as being bad code... I'm keeping my mouth shut on that one.. because I've been known to do the same thing.. I just can't believe we have made it so far
    into development without this being brought to anyone's attention.Didn't mean to offend you on the bad code. :) I thought the same ("how did it go so long?") when I found our problem (and many other problems in our code).
    So my options are pretty much
    1. change all double to BigDecimal
    2. use numberFormatter anywhere it is being
    converted to a string... or actually anywhere where
    the number can possible be longer then 7 characters
    long....Use a number formatter (such as DecimalFormat) everywhere. No need to figure out whether it is needed in each case.
    I think the best solution would be to switch to BigDecimal.. but that would take a MAJOR amount of
    work... I think there are around 6K java files in this project... probably every single one of them uses a double somewhere in the class...
    hmmm July 1st Beta test deadline might be hard to meet :)Same reason why we're stuck on Java 1.3.1 at work...deadlines and possible regression issues. :(

  • Double value truncated to two decimal places without rounding the value.

    I want to truncate double value to two decimal places without doing the rounding of the value.
    Is there any method which can directly do the truncation.

    There's many ways to achieve this such as using
    BigDecimal's setScale method or type-casting. This is
    the way I like to do it:double d = -5.239;
    d = d > 0 ? Math.floor(d * 100) / 100.0 : Math.ceil(d
    * 100) / 100.0;
    Your division by 100 may cause an rounding error, because there are numbers which no finite binary representation. That's splitting hairs! I know ;-)

  • Double Problem

    I am recently unable to download anything from the App Store.
    It just fails to download... all the time.
    Some days ago, I was sent an email verification mail; but whenever I try to verify, it says they are unable to verify the link I am using.
    What should I do?

    The problem is likely with the way the double is being formatted & displayed, not its actual binary value. Find the code where the double is converted to the string, and figure out who's doing the formatted (java.text.DecimalFormat?). That should point you in the right direction.

  • B540p double problem: loud noise and not working touch! Help please!

    Hello! I've bought an IdeaCentre B540pa (57314172) just 5 days ago. And suddenly two problems appeared. 1) My touch has ghost touching or self-touching. It's impossible to do anything. Sometimes for 5-10 minutes touch works ok, I can do things with fingers. But most of time it looks like a vertical line of self-touching fingerprints at the right side of lcd panel. 2) Even under little load my cooling fans going crazy! Diagnostic software shows diode gp (gt650m?) is overheated. Instantly temp rises till 93-95 degrees Celcium. Doesn't matter what I'm doing: surfing, or listening, or watching video. Due to something (they don't say why) local Lenovo service can't do repair. They say it's faulty motherboard and touch panel. They don't want to do a warranty repair. Instead they say to return my b540 back to shop, so the shop had that mess. But I want to try something by myself to repair, do something. 1) I opened back panels of b540 and now I see that when I push ON button to start the desktop a red diode is lighting up on touch board controller (a little board in the bottom middle). Is it normal or must be replaced? Will it solve the touch screen problem? 2) Recently I've read here at the forum, that people had similar problems with overheating. And that their problem was solved only with motherboard replacing. Is this the only solution? Of course I can return my desktop to the shop, and they will refund me. But I've paid 600$ for that b540, and there is no similar great desktops in that price range. At least in my city in Russia. They have b550 models, but they twice the price of my b540. I want to do something, make it work, and enjoy it with full specs: touchscreen, silent cooling, big screen etc. Please, help me deal with my thoughts and my b540p!

    Thanks for advice, but I have already tried to calibrate. Nothing.
    It's is very strange problem with touch. Right now, when I'm writing this the "auto-touch" or "selftouch", whatever name it, is zooming, moving page in the browser, and trying to make my life worse. The only way is to disable HID-compatible device is Device Manager. Another way is to have two or three fingers of a hand at the glass panel surface. It's strange but this action makes selftouch be under control. At least it stops zooming, moving. There is a little focus/unfocus problem, like screen is loosing and finds focus. Text goes a bit smaller, and again becomes bigger. I hope you understand what I'm trying to say.

  • Startup problem - "truncated or malformed library" flashing message

    I was updating the software on my iBook G4 (hadnt done so in a while so it was about 11 items) and i think the battery ran out or something as when i next looked the screen was black as if it had shut down.
    Now i cant seem to get it to startup again. The chime is heard then the grey screen with the logo appears but after that the screen goes black with a flashing message:
    dyld: -sh truncated or malformed library: /user/lib/libncurses.5.dylib (file is empty)
    underneath that is the date and time (still changing), followed by:
    init: single user shell terminated, restarting
    ...and its just stuck here. sorry i im not too familiar about what to do in this situation. thanks in advance.
    ibook G4 Mac OS X (10.3.4)

    Yes, you should be able to use the Install Disk for your other iBook, but you may have to install it in a particular way. However, I would suggest you trying to reset your NVRAM on the broken iBook. Follow these directions (from http://docs.info.apple.com/article.html?artnum=106482) to do this:
    1. Start up into Open Firmware by pressing and holding the Command-Option-O-F key combination during startup.
    2. At the Open Firmware prompt, type: reset-nvram
    3. Press Return.
    4. When prompted for your password, enter it and press the Return key. It responds OK.
    5. At the Open Firmware prompt, type: reset-all
    6. Press Return.
    The iBook should reboot and maybe it will boot Mac OS X. If not, you can do two things to try installing Mac OS X from your the Install Media for the other iBook.
    1) Try booting the broken iBook from the Install Disk by holding down the C key (until you see Mac OS X begin to boot) after turning the iBook on.
    2) If the Installer reports that your iBook isn't supported do this:
    a) Eject the Install Disk by holding down the mouse button while the iBook is booting.
    b) Put the broken iBook into Firewire Target Disk Mode and connect it to the other iBook. Turn on the other iBook and boot from the Install Disk. Choose to install Mac OS X on the drive in the broken iBook (which will appear as a Firewire hard drive in the Installer). Installing from a system specific Install Disk doesn't always work, but it's worth a shot. Good luck!
    PowerMac G5   Mac OS X (10.4.6)   1GB RAM, nvidia 6800 ultra, Apple 30" Cinema Display

  • JAXB Marshalling of "double" problem - exponent is in the way

    An element declared as "xsd:double" in the schema is marshalled by JAXB as "3.000404E-4" to represent 0.0003000404 . When I try to process this XML document using XSLT, the standard number() function returns "NaN" because of the exponent in the representation of the number.
    Is there any way to have JAXB marshall this number in a way that is acceptable to XSLT?
    Thanks,
    -Allan

    This seems to have a solution by using JAXB custom bindings. See http://forum.java.sun.com/thread.jsp?forum=34&thread=507037
    Thanks anyway.
    -Allan

  • Can anyone please explain this double problem?

    public class DoTest {
         static int i;
         public static void main(String[] args){
              double a = 3.0;
              double b = 0.3;
              double c = 0.3;
              double d = 0.3;
              System.out.println(c+a+b);
              System.out.println(d+c);
    }Result:
    3.5999999999999996
    0.6
    Why does the first println statement return 3.5999999999999996?
    Cheers

    import java.text.DecimalFormat;
    public class DoTest {
         static int i;
         public static void main(String[] args){
              double a = 3.0;
              double b = 0.3;
              double c = 0.3;
              double d = 0.3;
              double f=c+a+b;
              DecimalFormat df=new DecimalFormat("#.##");
              System.out.println(df.format(f));
              System.out.println(d+c);
    this is enougn for u man..
    do sme experiment wit it

  • Double problem: AirPort Utility 5.3.1 & Time Machine & AirPort Updater 1.0

    Few days ago. I updated the AirPort Utility 5.3.1. But then I cannot setup my old 802.11g AirPort Extreme Base Station (mushroom). AirPort Utility 5.3.1 can detect my AirPort Extreme Base Station: the name, IP Address, Version which is 5.5.1 and AirPort ID.
    Every time I clicked manual setup or continue, it reported "An error occurred while reading the configuration. Please make sure your Apple wireless device is plugged in and in range of your computer or connected via Ethernet and try again (-6765)."
    Today, more trouble. After installed the Time Machine and AirPort Updater 1.0. Not even problem not fix the problem and I can't re-install 10.5.2 update combo.
    Got error message "You cannot install Mac OS X Update Combined on this volume. This volume does not meet the requirements for this update."
    Repair disk permission help at all.
    Any methods can solve the above 2 problem please?
    Thanks

    mcdull wrote:
    Few days ago. I updated the AirPort Utility 5.3.1. But then I cannot setup my old 802.11g AirPort Extreme Base Station (mushroom). AirPort Utility 5.3.1 can detect my AirPort Extreme Base Station: the name, IP Address, Version which is 5.5.1 and AirPort ID.
    Every time I clicked manual setup or continue, it reported "An error occurred while reading the configuration. Please make sure your Apple wireless device is plugged in and in range of your computer or connected via Ethernet and try again (-6765)."
    Thanks
    I can help you with the first problem, as I experienced it myself. Airport Utiity cannot read your old "mushroom" base station until its firmware is upgraded to version 5.7. Because the Utility cannot configure it, you can download this and apply it directly:
    http://www.apple.com/downloads/macosx/apple/macosx_updates/airportextremefirmwar eupdate57formacosx.html
    Once applied, Airport Utility will configure the AEBS just fine.

  • Double double problems...

    Ok, I want to do simple opperations with my Double values, I want to be able to divide two Double variables:
    Double temp1, temp2, result;
                for(int k = 0; k < Array2.length; k++) {
                    temp1 = Array1[k];
                    temp2 = Array2[k];
                    if(temp1.compareTo(temp2) < 0) {
                        result+=(temp1/temp2);  // <----where i get this error "operator / cannot be applied to java.lang.Double,java.lang.Double"
                    sum++;
                }

    If I can't do that then how do I convert my Double Array so that I can read it into a normal double temp1?
    Suggestions?
        double temp1, temp2, result;
        Double[] Array1, Array2; <- this has to be Double.
                    // How can I convert the Array Double so I can read it to double then.
                    temp1 = Array1[k];
                    temp2 = Array2[k];

  • Problem to identify values in a case statement.

    Hi Friends,
    Total number of records in my report should be divided by 5 and to be alloted into 5 grades in Grade column.
    This is what I have done so far in my report with following layout.
    S.No - Col A - Col B - Col C - Grade ( Colums A,B,C will be hidden in Report)
    *****Column C will have only 5 values at max ( 0.0, 0.2, 0.4, 0.6, 0.8).The below example is for 6 records in a report.The same will be applied for 7,8,9,10 records.
    In column A: MAX(cast(RCOUNT(1) AS DOUBLE))/5 ( Ex : 6/5 = 1.2)
    In Column B: Truncate(MAX(cast (RCOUNT(1) as double)/5), 0) ( Ex : 6/5 = 1.0)
    In Column C: Col A- Col B ( EX:1.2 - 1.0 =0.2)
    (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0))
    Now In Grade coulum I want to use this column C to Grade the records with case statements in it.
    I am trying to use the following case statement for Grade Coulmn
    Case
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.0 then .........
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.2 then .............
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.4 then .............
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.6 then ........
    when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.8 then .....
    end
    Case statement works gud for 0.0 but not for other 4 values.
    It is unable to identify other 4values.
    Please tell me, how can I make case statement work for all values in above scenario.
    Thanks in Advance,
    Varsha.
    Edited by: Varsha on Nov 28, 2010 6:23 PM

    In column A: MAX(cast(RCOUNT(1) AS DOUBLE))/5 ( Ex : 6/5 = 1.2)
    In Column B: Truncate(MAX(cast (RCOUNT(1) as double)/5), 0) ( Ex : 6/5 = 1.0)
    In Column C: Col A- Col B ( EX:1.2 - 1.0 =0.2)
    (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0))Change the formula a bit by adding the by dim value for the MAX column.
    Column A: MAX(cast(RCOUNT(1) AS DOUBLE) by DimTable.Column)/5
    Column B: Truncate(MAX(cast (RCOUNT(1) as double) by DimTable.Column)/5, 0)
    Column C: MAX(cast(RCOUNT(1) AS DOUBLE) by DimTable.Column)/5 - Truncate(MAX(cast (RCOUNT(1) as double) by DimTable.Column)/5, 0)
    now write a case statement on top column c, based on your logic every 5th record will have a value 0.0
    Note: Dimtable.column is the table.column for which the row count is taken.
    Thanks,
    Vino

  • ALV: issue in truncating decimal values (rounding up)

    Hi,
    I have been receiving a problem truncating decimal values in alv environment using this abap code.
    WRITE gwa_komv-kwert TO gv_out_tax CURRENCY rte0143sf-currency
            DECIMALS l_decimals LEFT-JUSTIFIED.
    where l_decimals = 0.
    More exactly the value is rounded up but this is not my expectation.
    Any idea?
    Thanks.
        Giovanni

    Standard behaviour with DECIMALS 0: rounding up or own.
    And when you use the addition DECIMALS, then the CURRENCY addition is ignored as well.

  • Address Book Syncing Problems and Won't Restore

    I sync address book between two computers using .mac, and also publish it for another family member to use. This was working fine under Tiger, but I've recently noticed some issues in Leopard. Occasionally, instead of merging records, it will double them up. This morning, I noticed I had twice as many contacts as I should. For some reason, it added my entire .mac address book again back to my computer. Other times it had done that with only a few of the contacts.
    Fortunately, I had done an Archive my address book just the other day. Unfortunately, it didn't help. I went to restore from the Archive using "Import" and "Address Book Archive". It warned me it was about to replace my entire address book with the Archive, but then nothing happened. All my contacts disappeared, but then all of them came back again, still doubled. I know it was not doubled when I did the archive, so it didn't really restore my Archive.
    I finally fixed my doubled contacts problem by doing a one way sync from my second computer (which had not yet been affected by this) to .mac and then a one way sync from .mac to my laptop. I then turned off .mac syncing.
    Then, a little while later I had 20 more contacts! I realized that this came from the fact that the address book is published and the subscriber has editing rights. But she did not add them. It was again a doubling problem, this time in the sharing function. So I turned off editing in sharing.
    All is back now but I won't turn .mac syncing or shared editing back on until I understand what happened.
    Anyone else see these issues?

    leopard 10.5.1 on macbookpro. instructions to fix missing sync for my treo 650 including backing up (exporting) then restoring the address book. i also am unable to restore.
    the backup archive shows 6 MB.
    i click import, choose the archive, verify that i want to replace all. the address book then shows only the address that was highlighted before import, still shows 1152 cards, but no other cards are visible. verified the search box is empty.
    if i quit and restart address book, the original version of the address book is still there. apparently unable to import address book.
    -db

Maybe you are looking for

  • TS1424 Can l transfer money from my itunes account to my bank account account?

    Can l transfer money from my itunes account to my bank account?

  • [JTree]Block event?

    Hello, I've got a problem. In fact, i have a JFrame with on the left a JTree and on the right some JEditorPane and 3 JButton (New, Save, Cancel). When I clic on a JTree's Node, my JEditorPane are updated with desirated info. |-------------------|----

  • Oracle 9i Release 2 and Pro*C

    I installed Oracel 9i R2 on my XP platform, it runs well but one thing I found out is that Pro*C (used to be included in 9i Release 1) disappeared. Can anyone shed a light where I can find it? Thanks.

  • Adding new column to item overview tab of warranty claim

    Hi all,        I need to add an additional column to the item overview tab of the warranty claim.( transaction WTY ). If anyone has done this before then please send the details as to where and how this needs to be added.If added what are the necessa

  • Why is my voicemail indicator not working?

    The red circle is no longer displayed when I have new voicemails.  Have tried turning cellular data off and on.  Typically I am in WIFI and don't use cellular data.