This appears to be a case of a phenomenon called "Subtractive Cancellation" - 2nd year computer science mathematics stuff. When a floating point number is subtracted from another on a binary machine, the error is many times greater than when performing any of the other three basic arithmetic operations on two floating point numbers. Having said that, this case is particularly severe, as subtractive cancellation is usually only this noticable when two very large floating point numbers are subtracted from eachother to give a very small result. Nevertheless, it appears to explain what is happening here. I do remember being taught ways in which you can get around it and perform very accurate subtractions using floating point numbers (involving logs and exp and maybe even some trigonometric functions), but I'd have to delve into the old notes to find out, which I'm not likely to do ;-) Hopefully I've helped shed some light on *why* this is happening, but it doesnt help in solving it I'm afraid. Brad Wilson --------------------------------------------- BT Web Enterprises 5/44 Park Street North Woodville Park SA 5011 tel: (08) 8244 7760 fax: (08) 8244 7761 mob: 0419 848 707 email: [EMAIL PROTECTED] --------------------------------------------- ----- Original Message ----- From: "paul" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, December 22, 2000 11:09 PM Subject: Re: double value 10.20 -10.00 = ?? HELP! > ummmm.. Finite precision variables???? > > > I have the same problem with C++ program! > > I compiled with Borland C++ 5.5 compiler. > > > > float a = 1000000.20; > > float b = 1000000.00; > > float c = a - b; > > > > Result of c is 0.1875!!!!!!!! > > ???? > > > > We tried this on the same machine but on Linux operating system. Same > > problem with Java and C++ code! > > > > Nobody understand why is this hapening! > > > > Reinkarnation of old Pentium bug? > > > > Regards, > > > > =========================================================================== > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
Re: double value 10.20 -10.00 = ?? HELP!
Brad Wilson - BTWeb Enterprises Fri, 22 Dec 2000 21:50:07 -0800
- Re: double value 10.20 -10.00 = ?? HELP! Breskovac Mario
- Re: double value 10.20 -10.00 = ?? ... paul
- Re: double value 10.20 -10.00 = ... Brad Wilson - BTWeb Enterprises
- Re: double value 10.20 -10.00 = ?? ... Willard Thompson
