[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gm2] SHIFT questions

From: Iztok Kobal
Subject: Re: [Gm2] SHIFT questions
Date: Tue, 22 Dec 2009 16:35:47 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20091017 SUSE/2.0.0-1.1.3 SeaMonkey/2.0

If I read e.g. XDS M2 doc (see the things for me are more or less clear:

"A call of SHIFT shall have two actual parameters. The first parameter shall be an expression that is of a packedset type. The second parameter shall be an expression of a type with which the signed type is value parameter compatible."

Note: value parameter compatibility

That means: compile time (in case of constant 2nd argument) or run-time exception (in case of type range check was enabled and variable 2nd argument) when 2nd argument was greater than MAXBITS.

Otherwise (2nd argument was variable and no_of_shifts >= MAXBITS and no runtime type range check was enabled):

"With the interpretation of a value of type packedset as a sequence of bits, the shift operation can be considered as a zero-propagating logical-shift-up (left) operation or a logical-shift-down (right) operation, according to the value of the second operand, and within the bit field defined by the base type of the packedset."

Note: zero-propagating shift.

That means: propagating more than or equal to MAXBITS results in overall zeroed result.

This seems reasonable for me.

Regards, Iztok

Gaius Mulley wrote:

during the course of fixing some regression tests I came across
the problem of what to do if the user attempts to SHIFT by more
than set size bits.


    SHIFT(bitset, MAX(BITSET)+1)   is a no-op   MAX(BITSET)=31
                                   and shifting by 32 on a 32 bit
                                   machine yields the same result.

I cannot find how SHIFT should behave in the M2 ISO standard given
these parameters.  Currently if SHIFTing x where x is>MAX(settype)+1
will be the same as SHIFTing x MOD (MAX(settype)+1), for any settype.
Hope this is correct..


gm2 mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]