comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Byte/Bit Twiddling in Ada
Date: 1997/02/15
Date: 1997-02-15T00:00:00+00:00	[thread overview]
Message-ID: <dewar.856015719@merv> (raw)
In-Reply-To: 33048844.7AEB@elca-matrix.ch


Mats said

<<A(0 .. 15) := A(16 .. 31);  -- copy low-order 16 bits
                            -- into high order 16 bits

A(0 .. 30) := A(1 .. 31);  -- right shift
A := A(31) & A(0 .. 30);   -- rotate left>>


You are making entirely unwarranted assumptions about the mapping of
bit positions to high or low order, there is no such guarantee. Even
if you know the endianness, you cannot make such assumptions.

If you want a right shift, the portable way to write this is to use
the predefined right shift operation!

Note that in GNAT, the shift operators can be defined for any integer
type, including user defined ones, by writing the appropriate 
pragma Import (Intrinsic) declarations. This however is defintiely
NOT required to work by the RM. The only thing the RM guarantees is
that the predefined shift operations in interfaces will work.





  parent reply	other threads:[~1997-02-15  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5dvfnn$olj@neocad.xilinx.com>
1997-02-14  0:00 ` Byte/Bit Twiddling in Ada Mats Weber
1997-02-15  0:00   ` Robert Dewar
1997-02-15  0:00     ` wiljan
1997-02-26  0:00       ` Robert Dewar
1997-02-15  0:00   ` Robert Dewar [this message]
1997-02-14  0:00 ` Keith Allan Shillington
1997-02-14  0:00 ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox