Bug with double division ??

Hello,
first sorry my bad english...
I am trying to convert a C program in java and i had a big problem with double division.
For example, my program needs to do that :
double d = 2. * 3.1415926 ;
double d2=511;
double d3=d/d2;
The value in memory of d3 is 0x3f892e92965e074e whereas with my original C program, for the same code) the value in memory is 0x3f892e92965e074d !!!!!! (the last byte is different)
So what is the problem ? Is the double division in java different with the C language or is it my code which has a problem ??
Thanks a lot

It could be different than (some implementation of) C, but that doesn't mean it's a bug or a problem. Java is supposed to implement an IEEE floating point specification; if you can demonstrate that it's not following that spec (I think it's IEEE 754) then report it as a bug. Incidentally, do Java and your version of C implement 3.1415926 the same way?
(Also, if that number is supposed to be pi, then the inaccuracy you claim in Java is much less than the inaccuracy you made by using an approximation to pi.)

Similar Messages

  • SSIS importing comma delimited with double quote text qualifier - Works in VS - SQL Job ignores text qualifier and fails (truncation)

    I've created an SSIS package to import a comma delimited file (csv) with double quotes for a text qualifier ("). Some of the fields contain the delimiter inside the qualified text. An example row is:
    15,"Doe, John",IS2,Alabama
    In SSIS I've specified the text qualifier as ". The sample output in the connection manager looks great. The package runs perfectly from VS and when manually executed on the SSIS server itself. The problem comes when I schedule the package to run via SQL
    job. At this point the package ignores the text qualifier, and in doing so pushes half of a field into the next available column. But instead of having too many columns, it concatenates the last 2 columns ignoring the delimiter. For example (pipes are fields):
    15|"Doe| John"|IS2,Alabama
    So the failure happens when the last half of a field is too large to fit into the next available field. In the case above _John" is 6 characters where the IS2 field is char(3). This would cause a truncation failure, which is the error I receive from the
    job history.
    To further test this I created a failure flow in my data flow to capture the records failing to be pulled from the source csv. Out of ~5000 records, ~1200 are failing, and every one of the failures has a comma delimiter inside the quoted text with a 'split'
    length greater than the next ordinal field. The ones without the comma were inserted as normal and records where the split fit into the next ordinal column where also imported, with the last field being concatenated w/delimiter. Example records when selected
    from table:
    25|"Allan Percone Trucking"|GI6|California --Imported as intended
    36|"Renolds| J."|UI6,Colorado --Field position offset by 1 to right - Last field overloaded
    To further ensure this is the problem, I changed the csv file and flat file connection manager to pipe delimited, and sure enough every record makes it in perfectly from the SQL job execution.
    I've tried comma delimited on the following set ups. Each set up failed.
    SSIS Server 2008 R2 RTM
    DB Server 2008 RTM
    DB Compat 80
    SSIS Server 2008 R2 RTM
    DB Server 2008 R2 RTM
    DB Compat 80
    SSIS Server 2008 R2 RTM
    DB Server 2008 RTM
    DB Compat 100
    SSIS Server 2008 R2 RTM
    DB Server 2008 R2 RTM
    DB Compat 100
    Since a lot of our data comes in via comma delimited flat files, I really need a fix for this. If not I'll have to rebuild all my files when I import them to use pipe delimiters instaed of commas. I'd like to avoid the extra processing overhead if possible.
    Also, is this a known bug? If so can someone point me to the posting of said bug?
    Edit: I can't ask the vendor to change the format to pipe delimited because it comes from a federal government site.

    Just wanted to share my experience of this for anyone else since I wasted a morning on it today.
    I encountered the same problem where I could run the package fine on my machine but when I deployed to a server and ran the package via dtexec, the " delimeter was being replaced with _x0022_ and columns all slurped up together and overflowing columns/truncating
    data etc.
    Since I didn't want to manually hack the DTS XML and can't install updates, the solution I used was to set an expression on the textdelimiter field of the flat file connection with the value "\"" (a double quote). That way, even if the one stored in XML
    gets bodged somewhere along the way, it is overridden with the correct value at run time. The package works fine everywhere now.

  • Optimization bug with C++ inlining

    Hi,
    While evaluating Sun Studio 11 I have identified an optimization bug with C++ inlining.
    The bug can easily be reproduced with the small program below. The program produces
    wrong results with -xO2, because an inline access function always returns the value 0.0
    instead of the value given on the commandline:
    djerba{ru}16 : CC -o polybug  polybug.cc
    djerba{ru}17 : ./polybug 1.0
    coeff(0): 1.000000
    djerba{ru}18 : CC -o polybug -xO2 polybug.cc
    djerba{ru}19 : ./polybug 1.0
    coeff(0): 0.000000            <<<<<<<<<< wrong, should be 1.000000This occurs only with optimization level O2; levels below or above O2 don't
    exhibit the bug.
    Compiler version is
    Sun C++ 5.8 Patch 121017-01 2005/12/11
    on Solaris 8 / Sparc.
    I include a preliminary analysis at the end.
    Best Regards
    Dieter R.
    -------------------- polybug.cc -------------------------
    // note: this may look strange, but this is a heavily stripped down
    // version of actual working application code...
    #include <stdio.h>
    #include <stdlib.h>
    class Poly {
      public:
        // constructor initializes number of valid coefficients to zero:
        Poly() { numvalid = 0; };
        ~Poly() {};
        // returns coefficient with index j, if valid. Otherwise returns 0.0:
        double coeff(int j) {
         if (j < numvalid) {
             return coefficients[j];
         } else {
             return 0.0;
       // copies contents of this Object to other Poly:
        void getPoly(Poly& q) { q = *this; };
        // data members:
        // valid coefficients: 0 ... (numvalid - 1)
        double coefficients[6];
        int numvalid;
    void troublefunc(Poly* pC) {
        // copies Poly-Object to local Poly, extracts coefficient
        // with index 0 and prints it. Should be the value given
        // on commandline.
        // Poly constructor, getPoly and coeff are all inline!
        if (pC) {
         Poly pol;                      
         pC->getPoly(pol);
         printf("coeff(0): %f\n",pol.coeff(0));
    int main(int argc,char* argv[]) {
        double d = atof(argv[1]);
        // creates Poly object and fills coefficient with index
        // 0 with the value given on commandline
        Poly* pC = new Poly;
        pC->coefficients[0] = d;
        pC->numvalid = 1;
        troublefunc(pC);   
        return 0;
    The disassembly fragment below shows that the access function coeff(0), instead
    of retrieving coefficient[0] simply returns the fixed value 0.0 (presumably because the
    optimizer "thinks" numvalid holds still the value 0 from the constructor and that therefore
    the comparison "if (i < numvalid)" can be omitted).
    Note: disassembly created from code compiled with -features=no%except for simplicity!
    00010e68 <___const_seg_900000102>:
            ...     holds the value 0.0
    00010e80 <__1cLtroublefunc6FpnEPoly__v_>:
       10e80:       90 90 00 08     orcc  %g0, %o0, %o0      if (pC) {   
       10e84:       02 40 00 14     be,pn   %icc, 10ed4
       10e88:       9c 03 bf 50     add  %sp, -176, %sp
                                                       local Poly object at %sp + 120
                                                             numvalid at %sp + 0xa8 (168)
       10e8c:       c0 23 a0 a8     clr  [ %sp + 0xa8 ]      Poly() { numvalid = 0; };
                                                             pC->getPoly(pol):
                                                             loop copies *pC to local Poly object
       10e90:       9a 03 a0 80     add  %sp, 0x80, %o5
       10e94:       96 10 20 30     mov  0x30, %o3
       10e98:       d8 5a 00 0b     ldx  [ %o0 + %o3 ], %o4
       10e9c:       96 a2 e0 08     subcc  %o3, 8, %o3
       10ea0:       16 4f ff fe     bge  %icc, 10e98
       10ea4:       d8 73 40 0b     stx  %o4, [ %o5 + %o3 ]
                                                             pol.coeff(0):
                                                             load double value 0.0 at
                                                             ___const_seg_900000102 in %f0
                                                             (and address of format string in %o0)
       10ea8:       1b 00 00 43     sethi  %hi(0x10c00), %o5
       10eac:       15 00 00 44     sethi  %hi(0x11000), %o2
       10eb0:       c1 1b 62 68     ldd  [ %o5 + 0x268 ], %f0
       10eb4:       90 02 a0 ac     add  %o2, 0xac, %o0
       10eb8:       82 10 00 0f     mov  %o7, %g1
                                                             store 0.0 in %f0 to stack and load it
                                                             from there to %o1/%o2
       10ebc:       c1 3b a0 60     std  %f0, [ %sp + 0x60 ]
       10ec0:       d2 03 a0 60     ld  [ %sp + 0x60 ], %o1
       10ec4:       d4 03 a0 64     ld  [ %sp + 0x64 ], %o2
       10ec8:       9c 03 a0 b0     add  %sp, 0xb0, %sp
                                                             call printf
       10ecc:       40 00 40 92     call  21114 <_PROCEDURE_LINKAGE_TABLE_+0x54>
       10ed0:       9e 10 00 01     mov  %g1, %o7
       10ed4:       81 c3 e0 08     retl
       10ed8:       9c 03 a0 b0     add  %sp, 0xb0, %sp
    Hmmm... This seems to stress this formatting tags thing to its limits...

    Thanks for confirming this.
    No, this happens neither in an Open Source package nor in an important product. This is an internal product, which is continuously developed with Sun Tools since 1992 (with incidents like this one being very rare).
    I am a bit concerned with this bug though, because it might indicate a weakness in the area of C++ inlining (after all, the compiler fails to correctly aggregate a sequence of three fairly simple inline functions, something which is quite common in our application). If, on the other hand, this is a singular failure caused by unique circumstances which we have hit by sheer (un)luck, it is always possible to work around this: explicitly defining a assignment operator instead of relying on the compiler-generated one is sufficient to make the bug go away.

  • E71 Firmware Bug with USB Mass Storage.

    Hi,
    Just got a e71, it has the latest firmware, it's mostly good except for this bug.
    If you install a new theme on a memory card and then attempt to use the USB for mass storage it will always lock the card no matter how you disconnect from the USB, it always reports Memory card in use.
    What is supposed to happen is the phone is supposed to switch to a theme on the phone memory and unload the theme on the card, it does indeed switch themes, but does not unload the theme on the card, so the only way to free the card is to reboot the phone.
    If anyone from Nokia is looking at this forum, you guys need to fix these little bugs with the firmware.  A update to the OS the E71x is using would be nice by the way.  I paid a lot of money for this unlocked phone and expect it to be rock solid.

    I had this problem with the memory card. All you do is set the USB connection to PC suit and not Mass Storage. If it's in PC suit mode you don't loose the memory card and it always let you access it. I never bother with mass storage anymore. Also set to don't ask if you want. I ahve no issues since I di this and am using the 200 firmware.
    To transfer files to the card I go into my computer, double click the picture of the nokia E71 and then double click the memory card and access it that way. Hope this helps as it's a pain installing everything on the phone.
    Just another quick tip if you download the themes through your phone like me once installed and after a re-start something may try and install and fail once your phone starts up. It will do this everytime you re-start your phone. To fix the issue you have to browse the memory card with 'view hidden folders' selected in Windows and delete certain sis files from a certain folder. I can't remember off the top of my head but it explains it in another post in this forum. I can't take the credit for it.
    Ben 

  • [LR 4.1 - Library] Minor but annoying bug with mouse cursor

    Hi,
    There is a minor but irritating bug with the mouse cursor in the Library module. Steps to reproduce:
    1. Activate the Library module.
    2. Move the mouse cursor into the image area. The mouse cursor looks like a magnifying glass.
    3. Move the mouse cursor to the left, until it reaches the right border of the left panel. The cursor becomes a double arrow indicating that you can modify the left panel width.
    4. Do not click and continue moving the cursor to the left : most of the time (but not always) the mouse cursor is not reset to a standard cursor when entering the left panel area. It is still displayed as a double arrow.
    5. Sometimes this also occurs when moving the mouse cursor directly from the image area to the left panel.
    This can also happen under other circumstances. However, this doesn't happen with the right panel or when using another module. Also, at some time during the session, the problem disappears... until the next session or until you return from another module.

    I agree, although it sounds trivial, it is very irratating - especially when doing a lot of keywording.
    You could add your vote to a previously raised bug report on this ...
    http://feedback.photoshop.com/photoshop_family/topics/lightroom_4_library_module_keyword_l ist_cursor_problem
    Alan.

  • Is there a bug in 'Double'?

    When running the following code:
    public class Test {
    public static void main(String[] args) {
    System.out.println(273.15-25);
    the output is 248.14999999999998. To me, that looks like a calculation error. Surely, the answer is 248.15? There appears to be some kind of error with 'Double'. Of course, the answer is not far off with only 2e-14 less than the real answer. It is, none the less, very bothersome. Is there any way to gain correct decimal calculations when using Java, or do I have to use a different programming language? Or am I the real problem here... I do not think so.

    You have struck upon a problem as old as Babbage himself. Representations of floating point numbers in a binary system are almost impossible to do with complete accurracy.
    This is not a bug.. well... not a Java bug anyway. You'll find this behaviour in almost any language. IEEE 754 covers the specification for floating point arithmetic in binary systems.

  • ' ' bug with WebService not fixed in beta2

    Hi,
    There was a very popular bug in Flex3 with double escape, resulting in getting '&lt;' instead of '<'
    when using WebService, see bugs SDK-18321, SDK-15031, SDK-19811.
    That was fixed in SDK 3.5
    I just hit it with AIR2 beta2 app, same scenario.
    When does Adobe plan to fix it with Flex4 ?
    Any workarounds in Flex4 in the meantime ?
    Thank you,
    Oleg.
    Message was edited by: olegkon

    Yes, same thing here. Takes ages to lower to infinity.
    Wish it would be as fast as this:
    Create four nodes, open the Automation Event List (Ctrl Cmd E), change the second value to 0 (instead of 90) and hey presto, it gets very quiet indeed.
    /J

  • 30EA3: German language bug with user defined reports still not fixed

    In 30EA2: Limited folder functionality with German language
    I wrote about a bug in 30EA2. Was this message noticed by the developers?
    The bug still exists in 30EA3.
    In new folders for user definded reports only the options "Kopieren" and "Exportieren" (copy and export) are available, when SQL-Deverloper runs in German language mode.
    A workaround is to force language to English with the line
    AddVMOption -Duser.language=en
    in sqldeveloper.conf

    I made a new thread for the same bug in 3.1EA2:
    3.1EA2 Old bug with German language settings still exists
    I have some hope, that my problem finally got noticed by the developers.

  • 3.1EA2 Old bug with German language settings still exists

    In the past I wrote several times about a bug in SQL Developer when running in German language mode. This bug is still not fixed in 3.1 EA2:
    In new folders for user definded reports only the options "Kopieren" and "Speichern unter ..." ('Copy' and 'Cave as') are available, when SQL-Deverloper runs in German language mode. Other options like "Bearbeiten, Neuer Ordner, Neuer Bericht, Ausschneiden, Einfügen, Löschen" (Edit, New Folder, New Report, Cut, Paste, Delete) are missing. A workaround is to force language to English with the line
    AddVMOption -Duser.language=en
    in sqldeveloper.conf
    I mentioned it first in Re: Folders with limited functionality about version 2.1.1.64 and then in 30EA2: Limited folder functionality with German language 3.0 EA2 and German language bug with user defined reports still not fixed Beta Release 3.0 EA3
    Edited by: user1775992 on 22.11.2011 03:30

    I have raised a bug on this issue and I am actively looking into it.

  • How to replace single quote with double quote

    hai all,
    i have a problem,
    i am trying insert a string containing single quote into ms-access database.
    it is giving error.
    how can i avoid this .if i replace a single quote in the text with double quote it will defenitely
    insert into database.
    in java.lang.String
    replace () will not work to replace quote with double quote.
    any otherway to solve this problem.
    please mail me to [email protected]
    thank you
    sambareddy
    inida

    java.lang.String.replace () will not work to replace quote with double quote.Really?
    String x = ...
    x.replace( "'", "\"" );

  • Open sales order with changed Division

    Dear All ,
    here we have one query :
    material X , common in plant 1000 & 2000 .
    in plant 1000 we have division 40 , created sales order and partially delivered , after partial deliver i have changed division to common 00,
    now is it possible to deliver the remaining partial ?
    Regards

    Dear Venky
    First of all you should be aware that if you change the Division in basic data 1 for plant 1000, it will change for plant 2000 also
    Second, in order to do further delivery,
    -  Assign the division 40 to 00 in VOR2
    -  Assign the sales area in OVAZ (with cross division 00)
    thanks
    G. Lakshmipathi

  • Open file from table with double click

    Hi all,
    I use adf faces and JDEV 11.
    I want to open a file by double clicking on row in a table. (file is stored in the database).
    I first tried it with a button to open the file, with this code:
           System.out.println("Double click!");       
           BindingContainer bindings = this.getBindings();
            DCIteratorBinding iter = (DCIteratorBinding)bindings.get("XxahelpBezoekRapDocView1Iterator");
            Row row = iter.getCurrentRow();
            FacesContext fc = FacesContext.getCurrentInstance(); 
            HttpServletResponse response = (HttpServletResponse)fc.getExternalContext().getResponse();
            response.setHeader("Content-Disposition","attachment; filename=\""+row.getAttribute("Filename").toString()+"\"");
            response.setHeader("cache-control", "no-cache");
            try {
                InputStream in;
                in = ((BlobDomain)row.getAttribute("Bijlage")).getInputStream();
                ServletOutputStream out = response.getOutputStream();
                writeInputStreamToOutputStream(in, out);
                fc.responseComplete();     
            } catch (IOException e) {
                e.printStackTrace();
            } This is working fine.
    Now I wan't to open the file with double clicking on a row.
    For opening the file I use the same code in the backing bean and this code on the page:
          <f:facet name="metaContainer">
        <af:group>
            <trh:script>
               goEditRow = function(event) {
                    AdfCustomEvent.queue( event.getSource(), "doubleClickOnRow", {}, false);
            </trh:script>
        </af:group>
        </f:facet>And a clientListener and serverListener on the table:
    <af:clientListener method="goEditRow" type="dblClick"/>
    <af:serverListener type="doubleClickOnRow" method="#{backingBeanScope.backing_pages_EditTicket.doubleClick}"/>The only thing that happens when I double click is that I see "Double click!" in the console. But I can't save the file :S
    What is the problem?
    Thanks in advance.

    Hi
    What we do is to pick a table column for downloading the file.
    We change the component in the column to the an af:commandLink and add an
    af:fileDownLoadActionListener to the command link.
    The user clicks on the link to download (open) the file.
    Its not exactly the same as what you requested (double
    click on the row) but it might be another solution.
    Regards
    Paul

  • Single invoice for multiple orders with different divisions

    Dear All,
    while I am trying to do single invoice for muliple orders with different divisons invoice is gettting splitted..In copy control vbrk routine I  tried with 003 and 007 etc..but result is same..what configuration need to be done for getting the single invoice
    Thanks In advance
    Regards
    CNRNAIR

    Hello
    single invoice for multiple orders with "different divisions" invoice is getting split
    FYI - Different Division means different Sales Area.
    So, sales doc (whether sales order, Delivery & Billing) is applicable to EXACTLY one sales area.
    Thus, combining docs with different sales area is practically impossible.
    Provided, you are using common division.
    Hope this assist you,
    Thanks & REgards
    JP

  • Unable to close open apps with double clicking the button and when I tap screen does not respond?

    Cannot not close open apps with double clicking the button Since downloading iOS8.

    What happens when you try? Does double clicking the ?home button bring up the Task Bar of recently used apps? If so what happens when you flick up on the preview screen for the app you want to close?
    To quit an app double click the Home button to reveal the row of recently used apps. Flick up on the page preview and it will fly away and disappear. That quits the app.

  • Okay, i have 2 bugs with maverick.  First, when I delete a file within a window, the files deletes but the preview doesn't delete until I close the window and reopen it.  Second, I work on a network of computers and the search feature is now buggy...

    Okay, i have 2 bugs with maverick.  First, when I delete a file within a window, the files deletes but the preview doesn't delete until I close the window and reopen it.  Second, I work on a network of computers and the search feature is now buggy...  When I search for a file, A) it asks me if it's a name, or it wont produce anything, and B), its slower than in prior OS versions and in some instances I have to toggle to a different directory and go back to my original directory in the search: menu bar or the search wont produce anything...  Very buggy. 

    It appears to me that network file access is buggy in Maverick.
    In my case I have a USB Drive attached to airport extreme (new model) and when I open folders on that drive they all appear empty. If I right click and I select get info after a few minutes! I get a list of the content.
    It makes impossible navigate a directory tree.
    File access has been trashed in Maverick.
    They have improved (read broken) Finder. I need to manage a way to downgrade to Lion again.

Maybe you are looking for

  • Capturing footage to FCP 6.0.1 from Sony HVRZ1U HD Camera

    I'm doing an HD project using a Sony HVRZ1U camera. I'm capturing footage from a Sony HDV GV-HD700 deck. I get nothing in the viewer when I go to log and capture and I cannot capture anything when I press capture because there is no video signal. I c

  • Fatal bad_certificate

    Hi ! WebLogic Server 5.1 communicates with SAP Business Connector through HTTPS. We have set two-way authentication on. In case that WLS is the client and SAP BC is the server, WLS throws an IOException: Alert: fatal bad certificate. The certificates

  • Wipe Disk, install new OS, import some items from Time Mach.

    I read in another thread to use disk utility to zero my hard disk in the following manner: Creat another Admin User Use "erase" function to delete the space where my curretn user lives This is the best way to rid one self of legacy root junk that may

  • Blank maps (me too)

    Hi, my maps don't work in iphoto 09. I have tried all basics (replacing plist, turning firewall off, waiting for a long time, restarting, repaired permissions, etc.) but if I turn information on I don't see a map. I also cannot enter new places (it s

  • Filter conditions for Standard Idoc processing

    Hi Experts,        In BD64 - Distribution model  , I have created filters for MATMAS based on Division, Sales Organization, Distribution channel and Material Type.   when I process the IDoc through BD10 - Send material it is not getting filtered base