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/01 22:27:07 UTC

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

Author: jhardin
Date: Sun Sep  1 22:27:07 2019
New Revision: 1866247

URL: http://svn.apache.org/viewvc?rev=1866247&view=rev
Log:
use POSIX::ceil() in overlap percentage calculation so that <= 0.999% is not reported as "no overlap"

Modified:
    spamassassin/trunk/masses/hit-frequencies

Modified: spamassassin/trunk/masses/hit-frequencies
URL: http://svn.apache.org/viewvc/spamassassin/trunk/masses/hit-frequencies?rev=1866247&r1=1866246&r2=1866247&view=diff
==============================================================================
--- spamassassin/trunk/masses/hit-frequencies (original)
+++ spamassassin/trunk/masses/hit-frequencies Sun Sep  1 22:27:07 2019
@@ -23,6 +23,7 @@ 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,
@@ -955,8 +956,9 @@ sub _hmap_to_overlap_ratio {
   my $a2 = unpack("%32b*", $hmap2);
   my $a1_and_a2 = unpack("%32b*", ($hmap1 & $hmap2));
 
-  my $a1_in_a2 = int (($a1_and_a2 / ($a2 || 0.0001))*100);
-  my $a2_in_a1 = int (($a1_and_a2 / ($a1 || 0.0001))*100);
+  # 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);
 
   return ($a1_in_a2, $a2_in_a1);
 }