Mailing List Archive

[Bug 2987] $spam_score_int calculation for negative values is off-by-one
https://bugs.exim.org/show_bug.cgi?id=2987

Jeremy Harris <jgh146exb@wizmail.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Priority|medium |low

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2987] $spam_score_int calculation for negative values is off-by-one [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2987

Martin Kealey <from-exim-bugzilla@kurahaupo.gen.nz> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |from-exim-bugzilla@kurahaup
| |o.gen.nz

--- Comment #1 from Martin Kealey <from-exim-bugzilla@kurahaupo.gen.nz> ---
Welcome to the (horrible, ugly) world of casting floating point values to ints,
which causes "rounding towards zero".

Instead, perform an actual floating rounding:

EITHER for the intermediate value:

#include <math.h>
j = (typeof(j)) floor(spamd_score*10+0.5);

OR for the direct string result:

string_format(spam_score_int_buffer, sizeof(spam_score_int_buffer),
"%.0f", spamd_score*10);

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##