Commit 80a52686 authored by Ell's avatar Ell

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...
parent e8b37a7a
......@@ -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)
#define RINT(x) floor ((x) + 0.5)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment