-----Original Message----- From: James Sluka Sent: Monday, July 25, 2005 9:11 AM
> Robert's solution (rounding with sprintf) is pretty good, except it > requires that you know something about the numbers. you are correct about the limitations of floating point accuracy, but in this case you are making it unnecessarily complicated. John (the original poster) is adding a batch of floating point values that only have two decimal places. from his specific example, it does not appear that he needs or wants more accuracy than than the one one-hundredth place. for just two (or three or four or six!) decimal places, he doesnt need to worry about IEEE floating point standards, or the specifics of his architecture. > For example, they must differ by more than 0.01 to be considered different. not quite. example, when rounding to nearest 1/100th: 1.104 and 1.105 are different. this .001 difference is the minimum that can ever be measured as different. 1.105 and 1.114 are the same. this .009 difference is the maximum that can ever be measured as the same certainly there are Other Ways To Do It (tm) -- and probably "better" ways to do it -- but this method will always work for these types of numbers. ... Finally, if you're trying to do higher math functions that push the limits of your processor and/or require references to floating point standards, I'd say you probably shouldnt be using Perl. _______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
