X-Spam-Check-By: sourceware.org Subject: Re: Precision of doubles and stdio From: Jim Easton To: bagnara AT cs DOT unipr DOT it Date: Tue, 7 Mar 2006 04:04:14 -0700 (MST) CC: cygwin AT cygwin DOT com, Jim Easton Message-Id: X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com > Roberto Bagnara wrote: > ... > > $ a.out > > 70.9 > > 70.900000000000005684341886080801486968994140625 > ... > > $ ./a.exe > > 70.9 > > 70.90000000000000568434188608080148696899414 ... > Jim Easton wrote: > With all due respect, why would you want to? With double you are > guaranteed only 16 or so digits - the rest is noise. > > Jim Roberto Bagnara wrote: > Dear Jim, > > what is and what is not noise depends on the application. > In our applications we systematically use controlled rounding > on IEEE 754 floating point numbers. In the end, what we obtain > (in memory) are definite (i.e., provably correct) lower or upper > bounds of some quantities. ... > > Notice also that any IEEE 754 number can be (exactly!) printed > with a finite number of decimal digits. Finally, notice that > writing an algorithm to print them correctly is not rocket science. > Hence my astonishment when Tim showed me that the C standard > decided, instead, to allow blatant violations of the principle > of least astonishment :-) > All the best, > > Roberto Dear Mr. Bagnara, I see, or at least I think I understand. Most physicists, engineers, chemists etc. are interested in the most significant digits not the least. I don't think I need to try to explain why. Thanks for the explanation. To put this back in the realm of cygwin.com might I suggest that since having the exact value is important that you should write your own conversion routine thus not be subject to the vagaries of various systems. :-) No offense intended. Jim -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/