You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jh...@apache.org on 2019/09/02 19:10:48 UTC

svn commit: r1866290 - /spamassassin/trunk/masses/hit-frequencies

Author: jhardin
Date: Mon Sep  2 19:10:48 2019
New Revision: 1866290

URL: http://svn.apache.org/viewvc?rev=1866290&view=rev
Log:
ceil() is a little too aggressive, try rounding instead.

Modified:
    spamassassin/trunk/masses/hit-frequencies

Modified: spamassassin/trunk/masses/hit-frequencies
URL: http://svn.apache.org/viewvc/spamassassin/trunk/masses/hit-frequencies?rev=1866290&r1=1866289&r2=1866290&view=diff
==============================================================================
--- spamassassin/trunk/masses/hit-frequencies (original)
+++ spamassassin/trunk/masses/hit-frequencies Mon Sep  2 19:10:48 2019
@@ -23,7 +23,6 @@ use warnings;
 use FindBin;
 use Getopt::Long qw(:config bundling auto_help);
 use Pod::Usage;
-use POSIX;
 
 our (
   $opt_c, $opt_s, $opt_f, $opt_a, $opt_p, $opt_x, $opt_m, $opt_t, $opt_M,
@@ -956,9 +955,9 @@ sub _hmap_to_overlap_ratio {
   my $a2 = unpack("%32b*", $hmap2);
   my $a1_and_a2 = unpack("%32b*", ($hmap1 & $hmap2));
 
-  # use ceil() so that <= 0.999% is not reported as "no overlap"
-  my $a1_in_a2 = ceil (($a1_and_a2 / ($a2 || 0.0001))*100);
-  my $a2_in_a1 = ceil (($a1_and_a2 / ($a1 || 0.0001))*100);
+  # round rather than truncate
+  my $a1_in_a2 = int ((($a1_and_a2 / ($a2 || 0.0001))*100) + 0.50);
+  my $a2_in_a1 = int ((($a1_and_a2 / ($a1 || 0.0001))*100) + 0.50);
 
   return ($a1_in_a2, $a2_in_a1);
 }