Bug 788461 - Selection with a Fixed size is created with an ...

... off-by one size in special cases

The last commit wasn't drastic enough.  We changed SIGNED_ROUND()
to use RINT(), which, in turn, may use rint().  However, rint()
effectively breaks ties to even, so that we get stuff like
'rint (1.5) - rint (0.5) == 2.0 - 0.0 == 2.0'.  This can't be
good--it's entirely possible that we're bitten by this in other
cases without noticing.

Avoid rint() entirely in RINT(), and always use 'floor (x) + 0.5'
instead, which always breaks ties up.  Hopefully, this doesn't
break anything else...
This commit is contained in:
Ell 2017-10-05 17:35:10 -04:00
parent e8b37a7a25
commit 80a526861f
1 changed files with 7 additions and 1 deletions

View File

@ -64,7 +64,13 @@ G_BEGIN_DECLS
* This macro rounds its argument @x to an integer value in floating
* point format. Use RINT() instead of rint().
**/
#ifdef HAVE_RINT
#if defined (HAVE_RINT) && 0
/* note: rint() depends on the current floating-point rounding mode. when the
* rounding mode is FE_TONEAREST, it, in parctice, breaks ties to even. this
* is different from 'floor (x + 0.5)', which breaks ties up. in other words
* 'rint (2.5) == 2.0', while 'floor (2.5 + 0.5) == 3.0'. this is asking for
* trouble, so let's just use the latter.
*/
#define RINT(x) rint(x)
#else
#define RINT(x) floor ((x) + 0.5)