X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org From: "Dave Korn" To: References: <5abc24640709270814j5148c43ejbfe46f022fd6ad1b AT mail DOT gmail DOT com> Subject: RE: strange behavior with perl v 5.8.8 Date: Thu, 27 Sep 2007 16:46:58 +0100 Message-ID: <008b01c8011d$a3045a70$2e08a8c0@CAM.ARTIMI.COM> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <5abc24640709270814j5148c43ejbfe46f022fd6ad1b@mail.gmail.com> Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: 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 On 27 September 2007 16:14, Andrew Louie wrote: > Hello, > > I've run into a strange adding problem with perl: > > when incrementing by 0.1 ... an infinite, non-repeating fraction in binary floating-point, that can only be inexactly approximated ... > i get a strange behavior where at some > arbitrary number, it will append 0.9999999999 to the end of the > number. 'fraid so. Use rounding if you like. This is bog-standard floating point behaviour, part of the fundamental limitations of the representation. See, e.g. http://docs.mandragor.org/files/Programming_languages/C/clc_faq_en/C-faq/q14.1 .html http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems or in general google for "floating point accuracy". cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/