195706.11 + 4669.53 = 200375.63999999998 ?!? WTF?

I am writing a program that has to read transaction amounts from a file and add make sure that the previous balance + transactions = current balance. I have been getting errors that the accounts are out of balance because of things like this: 195706.11 + 4669.53 = 200375.63999999998, where the current balance is 200375.64. I have tried this on two different machines using JDK 1.3.1_02 and 1.4.0. Here's a program that demonstrates this:
public class DoubleTest {
     public static void main(String[] arguments) {
          double val1 = 195706.11;
          double val2 = 4669.53;
          double sum = val1 + val2;
          System.out.println(val1 + " + " + val2 + " = " + sum);
}I don't understand why this is happening! How can I trust my Java program if it can't even do simple primative arithmatic correctly?!?

I don't understand why this is happening! How can I trust my Java program if it can't even do >simple primative arithmatic correctly?!? I suppose you can't trust your Java program.
Computers store data in binary form base 2. Our numbering system is base 10. Conversion between base 10 integers and base 2 binary strings is rather simple, and there is no loss of precision.
Now throw in decimals. How would you store 4669.53 in 64 bits? How about 195706.11? Here's one 132.46747236823745349058436783248905789023478956072983478569879876894537906
Much more complicated, and there is a loss of precision. Not java's fault, just the way it works. If you can come up with an idea that will cover all decimals, then you, my friend, would be a rich man. I am willing to bet my left nut you can't.
Take a look at these
http://sandbox.mc.edu/~bennet/cs110/flt/dtof.html
http://www.cut-the-knot.com/blue/frac_conv.shtml
http://www.tpub.com/neets/book13/53i.htm

Similar Messages

  • CC, CC 64 Bit, and CC 2014? WTF?

    It's bad enough Adobe can't figure out how to make the same features in one program work the same in a different program. To top it off, instead of improving what are now "apps" and integrating we now have more new programs to do the same thing (e.g. not just one for website creation, not just one for photos, not just one for illustrations, not just one for animation, etc...) and to top it off again they get rid of important programs like Soundbooth, and stop upgrading ones we need like Encore. I am beginning to think the CC is for Creative Chaos not Creative Cloud....
    So, I uninstalled my CS5 master suite finally and moved presumably up to CC. But, now do I not only have more than one program to do the same thing more now I also have 3 of each! Wow! That's STUPID. Sorry, I hate using that word, but what in the hell?
    Why is it when I go to my programs I have a CC version, a CC 64 bit, and now new to the Creative Chaos we have CC 2014 versions!!!!          What? Really? Someone, please help me maintain my sanity. Before I realized it I was using Premiere CC then I inadvertantly started using CC 2014. Then I was like "something is missing, oh, wait, what? there's more than one version of premiere in CC???" Then I realized "oh, there's 3 of Illustrator, Photoshop, and inDesign?
    I of course have a 64 bit system, so should I only use the 64 bit versions and just delete the shortcuts to the others? and when there isn't a 64bit version but instead just a CC and a CC2014 version, which do I use? I mean, I assume the CC 2014. But, in 2014 will something change, will I be like "damn it, I should have been using the CC not the CC2014"?
    Adobe, please clean up all your software, boil it down to just the ones we need, we don't need more than one program to do THE SAME THING. and once you boil it down, don't give us three versions of it, ask "do you want the 64 bit version or the 32" and we'll be happy to download precisely what we need. Or better yet, figure out a way to make it work with one program. And, of course while you're at it combine the CC and CC XXXX version of each, WTF???

    32bit programs are installed for those people who use plugins that have not been updated to 64bit
    CC and CC2014 have different source code bases, so they are different programs
    http://blogs.adobe.com/jkost/2014/06/installing-the-2014-release-of-creative-cloud.html
    This messages says (at least some) CC 2014 programs use NEW plugins https://forums.adobe.com/thread/1499663
    -so do not uninstall the older CC programs if you use plugins in your programs until you are sure you have plugins that work in CC2014
    If you are sure you don't need the old CC programs
    -http://helpx.adobe.com/creative-cloud/help/install-apps.html to install or uninstall
    -read reply #3 about the ORDER of uninstalling & installing https://forums.adobe.com/thread/1242671

  • Cannot read the drop down menus on your addon page. WTF u trying to do?

    4.0 new. Looking for addons. I get to y9ur addon page and it's quite different from what I'm used to?WTTF! among other navigation quirks, I can not read your dropdown menus on the (Add-ons for Firefox - Collections - Mozilla Firefox 4 Collection) page. The menu, selected items, unselected items and everything else involved with the menuitems are all nearly the same color?WTF! Howto navigate?WTF! The total Firefox browser experience is lost when I am on the addons page?WTF!!

    You can find the Import menu entry in the Bookmarks Manager (Library)
    *Bookmarks > Show All Bookmarks > Import & Backup > Import Data from Another Browser
    *http://kb.mozillazine.org/Import_bookmarks
    See also:
    *https://support.mozilla.com/kb/how-do-i-get-firefox-button
    *https://support.mozilla.com/kb/why-are-tabs-top
    *https://support.mozilla.com/kb/common-questions-after-updating-firefox

  • ERROR: subscription expired but didn't,  did it? ... WTF?!

    Hello Adobe Support Team
    When trying to start Photoshop CC a error message pops up telling me that theres a
    problem with my subscription / account so I cannot longer use photoshop cc. I need to do some stuff today/tomorrow.
    So F*CK!  ( did he just write ..? yeah) The dialog also provides a link to my account management page. So I went there.
    Account Management View (subscription plans)
    Yay, clearly states "expired". So okay, then just re-new it right? Far from it!
    When I click on "Photoshop-Fotografieprogramm" I get the following info:
    WTF? On the right it shows me, that your SAP soap/web service configuration sucks. On the left side you are telling
    me, that my subscription is still valid and will be automatically re-newed on the fourth of mai 2015. You also provide me
    with two options: "upgrading" and "qutting" (which does nothing but showing a message that I need to contact support to
    quit. Thats cool. Straight forward UX - awesome!)
    Subscribing again from the Photoshop CC product page   did not work. Before the very last step in the
    order formular, a error message pops up, giving me the advice to try it later or change my browser. This one made my day.
    Tried several times now - it does not work.
    FIX THIS! Please.

    Hi,
    I got this too, the link to my post is here.
    POST
    I don't think you have to do anything as long as your account still has the credit card autorenewing.
    -Nick

  • WTF was sun thinking with MIDP 2.0?

    I've been working on some Java ME projects on my own time, outside of work, and it seems like practically whenever I try to save time, effort, and space by using the provided classes it instead leads to the complete opposite, which just pisses me off! There are a limited number of things that MIDP 2.0 added that are actually useful such as FullScreenMode, and ImageRotation fast enough to use realtime, practically everything else however seems to be tripe (WeakReferences and Floats are a CLDC 1.1 thing).
    Tonight's example: The Sprite class. I need the static fields from the class anyway for Graphics.drawRegion() calls, and since the class is provided for me, there's no reason to waste my time, and increase my jar size by writing and including a custom sprite class, particularly since at least some implementations probably don't suck (thanks SonyEricsson). OH WAIT, there is no accessor method for the image it refers to, and Offset and frameDimensions must be calculated from provided accessors, in the later case, a task that is impossible if your image is a block rather than a strip. This means that I am going to need to store another reference to the image in my class, that I ACTUALLY CAN access. 4 bytes * 200+ buildings = >800bytes heap wasted?
    Last night, it was the GameCanvas, that doesn't let you access the actual buffer image. If I want a canvas that can change orientations, and I extend from this, I basically have to triple buffer, and I hear that speedy graphics memory tends to be limited.
    Sun may have had reasons for these decisions, but seriously WTF were they thinking? What kind of mobile programming experience did the architects have? I really want to know. Are there plans to update any of these classes in the next revision?
    Edited by: Shroud on Sep 23, 2007 10:47 PM

    Sun may have had reasons for these decisions, but seriously WTF were they thinking? It's not SUN my dear friend. It's JCP. Every member of the JSR expert group which came up with this spec has an equal say in this!

  • WTF does this mean and why won't my illustrator CS5 load without this appearing??   Exit Code: 6 -------------------------------------- Summary -------------------------------------- - 0 fatal error(s), 5 error(s), 4 warning(s) WARNING: LocalizeFile:Local

    WTF does this mean and why won't my illustrator CS5 load without this appearing??
    Exit Code: 6
    -------------------------------------- Summary --------------------------------------
    - 0 fatal error(s), 5 error(s), 4 warning(s)
    WARNING: LocalizeFile:Localized string not found for locale 'en_GB' try fetching for en_US
    WARNING: LocalizeFile:Localized string not found for locale 'en_GB' try fetching for en_US
    WARNING: LocalizeFile:Localized string not found for locale 'en_GB' try fetching for en_US
    WARNING: LocalizeFile:Localized string not found for locale 'en_GB' try fetching for en_US
    ERROR: 92 Unable to copy file from "/private/tmp/.tempdirYoCObExG/Assets1/Application/Cool Extras.localized/en_GB/Sample Files/Sample Art/Crowd.ai" to "/Applications/Adobe Illustrator CS5/Cool Extras.localized/en_GB/Sample Files/Sample Art/Crowd.ai" Error 0
    ERROR: 92 Command ARKCopyFileCommand failed.
    ERROR: The following payload errors were found during install:
    ERROR:  - Adobe Illustrator CS5_AdobeIllustrator15en_GBLanguagePack: Install failed
    ERROR:  - Adobe Illustrator CS5: Failed due to Language Pack installation failure
    AND HOW DO I FIX THE PROBLEM???????

    Exit Code 6 and Exit Code 7 indicate that the installation finished with errors. However, the exit codes themselves do not indicate the type of error that occurred.
    Please refer to :
    Errors "Exit Code: 6," "Exit Code: 7" | CS5, CS5.5
    Error "Exit 6" or "Exit 7" | Install log | Read, write, system file errors | CS5, CS5.5
    Regards
    Rajshree

  • Jdk failed to create file in destination... WTF?!?!?!

    jdk failed to create file in destination...
    im trying to make my own private server and it just wont work! whenever i try it says jdk failed to create file in destination... and im gettin rlly frustrated...
    anyways.. im running windows vista and i need help. im not a computer whiz so try to make it as easy for me to understand and do rofl... i have EVERYTHING done for my private server but this! i really need help. i changed environment variables because i thought the dl worked and it didnt. someone plz help asap

    workman226 wrote:
    it's a runescape private server...
    (btw if it were any other type of server it wouldnt matter)
    and wtf does this have to do with the question?
    i need answers not more questions...You are unlikely to find anyone here on these Java developer forums that know about
    the particular Java application you have that you call a "runescape private server".
    If I were you I would look for help where you downloaded your "runescape private server"
    maybe they have some installation and troubleshooting guidelines?

  • [svn] 4669: Fix for - compiled SWF varies depending on version of java pointed

    Revision: 4669
    Author: [email protected]
    Date: 2009-01-26 11:00:48 -0800 (Mon, 26 Jan 2009)
    Log Message:
    Fix for - compiled SWF varies depending on version of java pointed
    QE Notes: Some mustella tests may need to be updated, as includes will be processed as per the order specified during compilation.
    Doc Notes: None
    Bugs: SDK-18168
    Reviewed By: Paul
    tests: checkintests, mxmlcunit
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-18168
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/CompilerAPI.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/CompilerSwcContext.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/common/Configuration.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/swc/SwcMovie.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/linker/FlexMovie.java

    Revision: 4669
    Author: [email protected]
    Date: 2009-01-26 11:00:48 -0800 (Mon, 26 Jan 2009)
    Log Message:
    Fix for - compiled SWF varies depending on version of java pointed
    QE Notes: Some mustella tests may need to be updated, as includes will be processed as per the order specified during compilation.
    Doc Notes: None
    Bugs: SDK-18168
    Reviewed By: Paul
    tests: checkintests, mxmlcunit
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-18168
    Modified Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/CompilerAPI.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/CompilerSwcContext.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/common/Configuration.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/swc/SwcMovie.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/linker/FlexMovie.java

  • CS6 new HTML 5 document uses XHTML DTD - WTF?

    We are suffering some serious weirdness.
    I am on Win7 with CS6 and my colleague is on OSX with CS6.
    We both do file, new, blank page, none, doctype html5
    I get a correct basic html5 page, he gets the XHTML DTD & extra stuff.
    We both have fresh installs, WTF is going on?

    I'm thinking a bad install or maybe bad permissions prevented some files from being installed. You could try re-creating the configuration folder: http://helpx.adobe.com/dreamweaver/kb/troubleshoot-javascript-errors-dreamweaver-cs4.html# main_user_config .  Another thing to consider is if you are using the same version of DW.  Just because you both have CS6 does not mean you are using the same version and the difference could be causing the error or an unknown bug.  The two versions out there are the traditional boxed/download license where you own the product and can buy upgrades and the other is the Cloud license which is operating on a different version.

  • Photoshop Elements 9...message when opening it: "This application has requested the Runtime to terminate it in an unusual way." WTF...?

    "This application has requested the Runtime to terminate it in an unusual way." WTF...?

    See this help document:
    https://helpx.adobe.com/photoshop-elements/kb/microsoft-c-runtime-error-launcing.html

  • Keep downloading Firefox 6.0.2 for Mac (as prompted) to my new Macbook Pro, running Lion (OS 10.7.1) and it won't open and install. WTF?

    I have Firefox version 3.6.22 (Mac) & keep downloading Firefox 6.0.2 for Mac (as prompted) to my new Macbook Pro, running Lion (OS 10.7.1) and it won't open and install. WTF?

    something similar has been happening to me for a a couple weeks (even before the most recent update, but now is definitely worse) on my 2010 MacBook Air. Firefox freezes upon startup, and then freezes maybe every twenty minutes or so when I'm actively using it, staying frozen for at least a minute or two. it drives me crazy.

  • ABAP General forum - 22 pages of posts in one day - wtf ?

    I don't have a project right now, so I was perusing the ABAP forum for whatever looked interesting.
    I noticed 22 pages of posts just today 11 Feb. With 15 posts per page that's 330 post/replies in one day!
    WTF is up with that, a little too crazy isn't it ?

    The turnover in the ABAP Development forums has always been fast (hence also the temptation to duplicate post, instead of following up with more infos from having made some headway on your own while waiting for answers)...
    Since a few days, there has been a steady increase and it is very busy at the moment.
    I am not sure what the equilibrium thread-per-minute rate is before people reach the search-first-coeffecient, but it is approaching hopefully.
    I am trying to look on the bright side of it...
    Cheers,
    Julius

  • Wtf happened to my external harddrive?

    Yesterday I borrowed the external harddrive from my dad, because I wanted to dd the Snow Leopard Mac OS X image on it, to install it via usb on my netbook (I have done it before). After I finished dding I connect the external harddrive on my netbook, at first it works. But like 10mins later, it isn't recognized anymore. So I connect it to my arch PC and dmesg shows this:
    [  923.363317] hub 7-0:1.0: Cannot enable port 1.  Maybe the USB cable is bad?
    [  926.433352] hub 7-0:1.0: Cannot enable port 1.  Maybe the USB cable is bad?
    [  929.503345] hub 7-0:1.0: Cannot enable port 1.  Maybe the USB cable is bad?
    [  932.573359] hub 7-0:1.0: Cannot enable port 1.  Maybe the USB cable is bad?
    [  932.573379] hub 7-0:1.0: unable to enumerate USB device on port 1
    I tried many different ports, doesn't work. Other USB devices work just fine.
    So wtf happened? is the USB cable really bad? (I can't believe it, because it worked just fine before ...)
    Is the harddrive broken? when I connect the power cable to the harddrive and turn it on it still loads up tho.

    Did you try the hard on any other PC? Do "fdisk -l" and "lsusb" recognize it?

  • Java provides a Firewall WTF?

    i was taking a terrible java core practice test today online and this was one of the questions:
    Java provides a Firewall between a networked application and your computer.
    TRUE/FALSE
    i said false, they said i was wrong.
    Does anyone know wtf they are talking about here ?

    bah, why was it the first hit on google!!:shrug:
    Why indeed. A good bit of googlebombing I would guess. It really is a terrible reference. It has been discussed here before. If you browse through the questions and answers you will find that the answers break down like this.
    30% correct (if that)
    30% have a grain of truth but largely stuff and nonsense
    30% out and out bullshit
    10% so poorly answered you they don't even seem to be answering the same question
    And then there are the threads that are just scary like...
    http://www.geekinterview.com/question_details/38346
    The answer is a joke of course but the question... I pray it is a joke too.

  • Posts are duplicating like bunnies when I edit them in Posterous since the latest Beta Update??? wtf?

    When I go to edit any post on my [http://whatgetsmehot.posterous.com Posterous] blog, the html and media including photos and videos are duplicating like bunnies if i do any editing (like going from rich format to html and back) all since the latest Beta Update??? And after that it will crash because it has multiplied anywhere from 4X to ?X times.
    I submitted a crash report today but i didn't save the info
    I've, of course, done all the usual (or i wouldn't be here). Cleared Cache multiple times...there were some funky warnings coming from the error page thing about co-something or other and this is what i have tonight: Warning: Error in parsing value for 'background-image'. Declaration dropped.
    which i realize is nothing...
    I have never heard of this at all.
    Btw, I uninstalled all my addons and am running on nothing but what comes with my Windows XP and from FF.
    Any thoughts?
    4.0b7 Windows XP * Shockwave Flash 10.1 r102 * Next Generation Java Plug-in 1.6.0_22 for Mozilla browsers
    * NPRuntime Script Plug-in Library for Java(TM) Deploy
    Please confirm your question (Posts are duplicating like bunnies when I edit them in Posterous since the latest Beta Update??? wtf?) at the link below:
    https://support.mozilla.com/questions/765050/confirm/BwFoMXRaWX

    What is a fresh restore?  I'm sorry but I'm not up on the lingo LoL but I'll give it a shot if I know what I have to do>

Maybe you are looking for

  • Safari crashes and won't open.

    New Bee here and after searching and trying most everything, I had no luck and to post this error msg I get every time I try to open Safari. I have no Genieo as I looked for it. Your help is appreciated. Rgds Elvin Process:           Safari [847] Pat

  • Fields under the tab Goods Receipt in process order.

    Hello Experts, While creation of process order, the fields under the tab 'Goods Receipt' are disabled and already checked. Fields are 'Goods Receipt' and 'Goods Receipt, Non-Valuated'. Fields are 'WEPOS' and 'WEUNB' accordingly. Whereas when we creat

  • Issues after ICS Update to Neo V

    1. Performance lag is there although I have removed many apps and Internal memory as well as RAM available is more than what it was earlier. Any suggestions? 2. Apps crash. The most worrysome is the scenario when you are not able to receive a call be

  • What is the best way to export/share GarageBand files with a non-mac user?

    I have some GB2 files, too big to email, that I want a client to hear and give direction. then I can make the changes and re-export them for him to hear again. What is the best way to do this? IMac seems to be forthcoming about sharing pictures and I

  • Exception while Deserializing objects..

    There's a class which is serialized, and stored in the DB. Now, this class is changed (there's an attribute added) and there's new instances which are not stored in the DB. But the problem now comes when I have to deserialize both these instances. At