Bugs or features?

Roberto Bagnara bagnara at cs.unipr.it
Sat Feb 16 07:55:50 CET 2008


Torbjorn Granlund wrote:
>   I am just wondering if this is by design or if this is a bug?
> 
>   The question if this is the intended functionality of the >>= operator
>   for negative numbers. This differs from how it is defined for native
>   types like int for example.
> 
> This is a sticky issue.
> 
> In the C standard, the behaviour of right shift of negative numbers is
> undefined.  But in practice, almost every compiler defines it as
> rounding towards -oo.  The one exception I am aware of is Cray's
> compilers for their vector systems.  (They shift the numbers logically
> always, which is not very helpful.)
> 
> I am inclined to changing gmpxx.h to make it follow the common
> behaviour, although that is not formally standardized.
> 
> What do people think?  I am mainly interested in the opinion of people
> that actually use gmpxx.h.

I vote for the proposed change.

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it


More information about the gmp-discuss mailing list