----- Original Message ----- From: "Electron One" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, August 08, 2003 6:54 AM Subject: Precision on addition Problem
> Hi all, > > I am experiencing an issue when I try to add a decimal multiple times in a > for loop. This really > throws off my calculations when I need such accurate analysis. If anyone > can provide a reason > for this occurrence or a way to stop this from happening I would greatly > appreciate it. > > I am running this on a Unix os 2.8 machine. > > CODE: > > #!/pkg/iceng/perl5/5.8.0/bin/perl > > ## standard perl modules ## > use strict; > > my ($a, $i, $t); > > $a = 10.01; > > for($i=0; $i<2000; $i++) { > $t += $a; } > > print "TOTAL: $t\n"; > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > OUTPUT: > > TOTAL: 20019.9999999997 > > > > Any help would be appreciated. > Jay Flowers provided this link a while back: http://www.samag.com/documents/s=1277/sam02040001/ It covers the issue pretty well, imo. Cheers, Rob _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs