[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work2) now available
- From: Coroutines <coroutines@...>
- Date: Wed, 26 Mar 2014 23:37:58 +0000
On Wed, Mar 26, 2014 at 10:28 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> I'm a bit ashamed to say that i do lol. Signum for example:
>>
>> static inline int sgn2(int x) { return (x != 0) * (1 | (x >> ((sizeof(x) * 8) - 1))); }
>
> "Hacker's Delight" suggests this:
>
> -(x >> K) | (-x >> K), where K = sizeof(x) * 8 - 1.
>
> No conditionals, no multiplications, two logical shifts and three one-clock
> instructions (2 subs and 1 or).
>
> -- Roberto
>
...and a partridge in a pear tree ^__^
- References:
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available, Coda Highland
- Re: [ANN] Lua 5.3.0 (work2) now available, Dirk Laurie
- Re: [ANN] Lua 5.3.0 (work2) now available, Coda Highland
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available, Tim Hill
- Re: [ANN] Lua 5.3.0 (work2) now available, Enrico Colombini
- Re: [ANN] Lua 5.3.0 (work2) now available, Tim Hill
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available, Tim Hill
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy