[PATCH] Don't cast double to int: use default conversions or explicitly round.

Simon Thum simon.thum at gmx.de
Thu Oct 29 06:39:04 PDT 2009

Jamey Sharp wrote:
> -m->LO1I=(int)floor((m->f_lo1/f_ref)+0.5);
> +m->LO1I=lrint(m->f_lo1/f_ref);
As you seem to be the second in-server user of the lrint() gang, I'd
like to ask for any insights concerning this:

So far, I'm worried whether it isn't better to ditch the implicit
conversions as well (ie. dump floor&ceil, though that sounds ugly). But
that's just because I don't have any explanation why exactly the fix in
the bug did work.

> +++ b/hw/xfree86/parser/Flags.c
> @@ -434,7 +434,7 @@ xf86uLongToString(unsigned long i)
>  	char *s;
>  	int l;
> -	l = (int)(ceil(log10((double)i) + 2.5));
> +	l = ceil(log10((double)i) + 2.5);
doesn't lrint(...+3) match better with the rest?



More information about the xorg-devel mailing list