Re: [dev] [st] [PATCH] Explicit cast in CEIL macro

From: Markus Teich <markus.teich_AT_stusta.mhn.de>
Date: Tue, 24 Jun 2014 19:52:53 +0200

FRIGN wrote:
> We are dealing with floats with at most 2 decimal places.

Heyho,

in this case you could also argue, that this macro is only used to get an upper
bound for the character size in st and not for the least upper bound and then
use the even simpler version with CEIL(3.0) == 4.

But, as this macro may be used by other contributors for other reasons we do not
know yet and they could as well need more precision. If not in st, someone could
copy the macro and fail horribly with his application. It is very misleading to
define a macro which suggests to do the same thing as a well known standard
library function does, but it indeed behaves differently in some cases. This
definitely should be worth the -lm for correctness' sake.

Otherwise you could just get rid of the misleading macro and use

xw.cw = (int)dc.font.width * cwscale + 1;
xw.ch = (int)dc.font.height * chscale + 1;

instead, ignoring the maybe wasted pixel.

--Markus
Received on Tue Jun 24 2014 - 19:52:53 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 24 2014 - 20:00:13 CEST