ch_tang
New User
Sep 11, 2009, 6:05 PM
Post #1 of 3
(891 views)

Subtraction Error using Perl

Can't Post


Hi All, I observed the following abnormality while running my PERL program calculating student t test test statistics value. Hope you can help. Thanks in advance. $t0 = ($mean1  $mean2)/(sqrt($varp*(1/$n1+1/$n2))); $mean_diff = $mean1  $mean2; I printed the value of the variable in the equation: print "($mean1  $mean2) $mean_diff /sqrt($varp*(1/$n1+1/$n2)) = $t0\n"; The results was as below: $mean1$mean2 $mean_diff /sqrt($varp*(1/$n1+1/$n2)) = $t0 (0.61  0.61) 1.11022302462516e16 /sqrt(8.40561424617007e32*(1/39+1/35)) = 1.64465938636703 Which was puzzling. Shouldn’t 0.61 – 0.61 result to 0? This screwed up my test statistics and wonder if any of you can help work around this issue? Do I need to load any additional perl mathematics module to calculate this properly? I expected $t0 to be 0 since the numerator should be a 0.
