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

From: FRIGN <dev_AT_frign.de>
Date: Tue, 24 Jun 2014 15:33:10 +0200

On Tue, 24 Jun 2014 08:50:01 +0200
"Roberto E. Vargas Caballero" <k0ga_AT_shike2.com> wrote:

> I think a correct version may be:
>
> CEIL(x) ((int) (x) + ((x) > 0 ? 1.0 : 0.0))
>

This is not quite right, given we want to return an int (according to
xw.ch, xw.cw and common sense (ceilf doesn't make sense)), it should
rather be:

CEIL(x) ((int) (x) + ((x) > 0 ? 1 : 0))

However, I favor Martti's verson, which is just plain genius:

CEIL(x) ((int)(x) + ((x) > 0))

Cheers

FRIGN

-- 
FRIGN <dev_AT_frign.de>
Received on Tue Jun 24 2014 - 15:33:10 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 24 2014 - 15:36:06 CEST