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/