Re: How do you bitwise operations in Ada '83 and '95

On Sat, 22 Jul 2006 12:52:29 +0200, Georg Bauhaus wrote:

On Sat, 2006-07-22 at 10:32 +0200, Dmitry A. Kazakov wrote:

Does ANSI C standard require (x<<1) == (x*2)?

As for Ada 95, ARM certainly does not. This is why Shift_* is not portable.

type Unsigned_n is mod 2**n; -- Annex B.2

won't be portable for the same reason?

Why? Semantics of modular arithmetic is defined in a portable way. As long
as you deal with *numbers* everything is OK.

As for the bit representation of these intrinsic modular values,
wouldn't shift_left etc. have to provide a result that does
make sense, as per the AS-IF rule?

I am not a language lawyer. To me shifts aren't numeric operations, but
ones on arrays of bits. Mixing both is asking for trouble.

Dmitry A. Kazakov