On Tue, Jun 24, 2014 at 3:19 PM, FRIGN <d...@frign.de> wrote: > On Tue, 24 Jun 2014 09:13:11 +0200 > Martti Kühne <mysat...@gmail.com> wrote: > >> #define CEIL(x) ((int)(x) + ((x) > 0)) > > Martti, you definitely are a candidate for the best macro-hack of > 2014 ;). >
Here's another one. Non-branching sign extraction... #define SGN(x) (2 * ((x) > 0) - 1) More food for thought in [0] cheers! mar77i [0] https://graphics.stanford.edu/~seander/bithacks.html