- printf($format, $$m_count{$key}, volume_rounded($$m_data{$key},$$m_data_gigs{$key}), $htmlkey);
+
+ # When displaying the average figures, we calculate the average of
+ # the rounded data, as the user would calculate it. This reduces
+ # the accuracy slightly, but we have to do it this way otherwise
+ # when using -merge to convert results from text to HTML and
+ # vice-versa discrepencies would occur.
+ $rounded_volume = volume_rounded($$m_data{$key},$$m_data_gigs{$key});
+ $data = $gigs = 0;
+ un_round($rounded_volume,\$data,\$gigs);
+ $count = $$m_count{$key};
+ $rounded_average = volume_rounded($data/$count,$gigs/$count);
+ printf($format, $count, $rounded_volume, $rounded_average, $htmlkey);