[Top][All Lists]

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

**From**: |
Paul Eggert |

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

**Date**: |
Fri, 10 Dec 2010 12:03:15 -0800 |

**User-agent**: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101027 Thunderbird/3.0.10 |

On 12/10/10 09:33, Ben Pfaff wrote:
>* Is it even necessary to drag the preprocessor into it?*
>* *
>* if (-1 >> 1 == 1)*
Yes, good point: in many cases that suffices,
and if it works it's typically better to avoid the
preprocessor.
On 12/10/10 09:17, Andrew W. Nosenko wrote:
>* Why do you think that preprocessor should match the*
>* behavior of compiler???*
Because in practice, when they don't, Bad Things Happen,
this being one of the least of the problems. Generally
speaking, it's not worth worrying about mismatches when
one mixes a preprocessor from source A (or for machine A)
with a compiler from source B (or for machine B).
For example, if LONG_MAX from the preprocessor is less than the
actual maximum long int value supported by the compiler, then
it's better to treat the weird compiler+preprocessor behavior
as being buggy, and to fix the bug rather than contort the
code with some complicated Autoconf test. Alternatively,
if it's easy, it's even better to modify the code so that
it works regardless of whether LONG_MAX is truly the maximum
long int value; this avoids the need for any Autoconf
or other test.
The situation with -1 >> 1 is similar.

**Re: Arithmetic Shift**, *(continued)*
**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*, `2010/12/10`
**Re: Arithmetic Shift**, *Ben Pfaff*, `2010/12/10`
**Re: Arithmetic Shift**,
*Paul Eggert* **<=**
**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`