Re: [dev] [st] [PATCH] Explicit cast in CEIL macro
On Tue, Jun 24, 2014 at 8:50 AM, Roberto E. Vargas Caballero
<k0ga_AT_shike2.com> wrote:
> CEIL(x) ((int) (x) + ((x) > 0 ? 1.0 : 0.0))
>
> Positive:
> CEIL(3.3) => 3 + (3.3 > 0 ? 1.0 : 0.0) => 4.0
>
> Negative:
> CEIL(-3.3) => -3 + (-3.3 > 0 ? 1.0 : 0.0) => -3
>
here's a shorter equivalent:
#define CEIL(x) ((int)(x) + ((x) > 0))
cheers!
mar77i
Received on Tue Jun 24 2014 - 09:13:11 CEST
This archive was generated by hypermail 2.3.0
: Tue Jun 24 2014 - 09:24:06 CEST