Re: Use of lrint() in 'gdk-pixbuf/pixops/pixops.c'
- Date: Sun, 5 Feb 2017 11:33:53 +0100
- From: Martin Guy <martinwguy@xxxxxxxxx>
- Subject: Re: Use of lrint() in 'gdk-pixbuf/pixops/pixops.c'
On 05/02/2017, Yale Zhang <yzhang1985@xxxxxxxxx> wrote:
> I suggest adding a lrintf() fallback to fallback-c89.c too.
> Currently, there are 2 rounding functions in the fall backs, round()
> and rint(), with rint() having the better less biased IEEE
> round-to-even behavior for the 0.5 case.
> lrintf() is preferable because it can be done in a single instruction
> (round and convert to int) on x86, while (int)round(x) would need 2
i have a nasty feeling that that's why I used it instead of the more
obvious code, having read a rant a few months ago about the wonders of
lrintf compared to native type conversions in some case where it made
a lot of difference.
In this case, both speed and precision are not issues as it's only
done once, only in high-scale reductions and precision is not
important here. Dropping the 0.5 would make no difference. I think I
was just being a bit too clever.
In general, I suppose adding a fallback lrintf would mean that if
anyone else used it in future, the same issue wouldn't crop up again -
and if that's a valid reason to add complexity, one should probably
implement fallbacks for the whole family - lrint, lrintf, lrintl,
llrint, llrintf, llrintl.
gtk-devel-list mailing list