[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: Arithmetic Shift

**From**: |
Dave Goodell |

**Subject**: |
Re: Arithmetic Shift |

**Date**: |
Fri, 10 Dec 2010 13:31:08 -0600 |

On Dec 10, 2010, at 11:33 AM CST, Ben Pfaff wrote:
>* Paul Eggert <address@hidden> writes:*
>* *
>*> On 12/07/10 20:41, Mike Gibson wrote:*
>*>> Does a test already exist that checks for if the >> operator in C does*
>*>> arithmetic shift?*
>*> *
>*> Doesn't this suffice, without dragging Autoconf into it?*
>*> *
>*> #if -1 >> 1 == -1*
>* *
>* Is it even necessary to drag the preprocessor into it?*
>* *
>* if (-1 >> 1 == 1)*
Careful, that expression will probably always evaluate to false. Although
there is always the unlikely possibility of other cases, there are only two
sensible values that (-1 >> 1) can evaluate to. The first is the result of an
arithmetic shift, which means that it would be -1. The second would be the
result of a logical shift, or (2**(CHAR_BITS*sizeof(int)-1)-1), probably
2147483647 for most platforms.
-Dave

**Re: Arithmetic Shift**, *(continued)*
**Re: Arithmetic Shift**, *Paul Eggert*, `2010/12/09`
**Re: Arithmetic Shift**, *Mike Gibson*, `2010/12/09`
**Re: Arithmetic Shift**, *Andrew W. Nosenko*, `2010/12/10`
**Re: Arithmetic Shift**, *Paul Eggert*, `2010/12/10`
**Re: Arithmetic Shift**, *Peter Breitenlohner*, `2010/12/10`
**Re: Arithmetic Shift**, *Andrew W. Nosenko*, `2010/12/10`
**Re: Arithmetic Shift**, *Bob Friesenhahn*, `2010/12/10`
**Re: Arithmetic Shift**, *Andrew W. Nosenko*, `2010/12/11`

**Re: Arithmetic Shift**, *Ben Pfaff*, `2010/12/10`
**Re: Arithmetic Shift**,
*Dave Goodell* **<=**
**Re: Arithmetic Shift**, *Ben Pfaff*, `2010/12/10`
**Re: Arithmetic Shift**, *Paul Eggert*, `2010/12/10`
**Re: Arithmetic Shift**, *Andrew W. Nosenko*, `2010/12/11`
**Re: Arithmetic Shift**, *Paul Eggert*, `2010/12/11`
**Re: Arithmetic Shift**, *Andrew W. Nosenko*, `2010/12/11`
**Re: Arithmetic Shift**, *Andrew W. Nosenko*, `2010/12/11`