[Top][All Lists]

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

Re: [Gm2] SHIFT questions

From: Gaius Mulley
Subject: Re: [Gm2] SHIFT questions
Date: Tue, 22 Dec 2009 21:07:00 +0000
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Iztok Kobal <address@hidden> writes:

> 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.

Hi Iztok,

thanks for the explanation - I missed the implications of "value
parameter compatibility" (range of set type).  This is nice as it
allows the compiler to perform checking and it will be pretty useful
to enable runtime checks, I've been bitten by C shift operators before
now :-)


reply via email to

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