[exim-dev] [Bug 2987] $spam_score_int calculation for negati…

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: admin
Dátum:  
Címzett: exim-dev
Tárgy: [exim-dev] [Bug 2987] $spam_score_int calculation for negative values is off-by-one
https://bugs.exim.org/show_bug.cgi?id=2987

Martin Kealey <from-exim-bugzilla@???> changed:

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


--- Comment #1 from Martin Kealey <from-exim-bugzilla@???> ---
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.