comp.lang.ada
 help / color / mirror / Atom feed
From: "(see below)" <yaldnifb@blueyonder.co.uk>
Subject: Re: Any examples of Byte Ordering Functions
Date: Sun, 19 Oct 2003 17:25:28 GMT
Date: 2003-10-19T17:25:28+00:00	[thread overview]
Message-ID: <BBB8876D.609E0%yaldnifb@blueyonder.co.uk> (raw)
In-Reply-To: ZUxkb.3653$KA5.30672@newsfep4-glfd.server.ntli.net

On 19/10/03 16:22, in article
ZUxkb.3653$KA5.30672@newsfep4-glfd.server.ntli.net, "chris"
<spamoff.danx@ntlworld.com> wrote:


> Trivial? :(  Can you tell me how to do it pls?
> 
> I have the following:
> 
> type byte is mod 256;
> type word is mod 2**16;
> type dword is mod 2**32;
> 
> for byte'size use 8;
> for word'size use 16;
> for dword'size use 32;
> 
> 
> I can do stream -> word and back using multiplication/division for big
> and little endian, but not dword.


You can use shifts, ands (for masking) and ors (for combining) bit patterns
in unsigned types as easily in Ada as in C. (gasp!) No need to rely on the
compiler sussing out your arithmetic.

-- 
Bill

P.S. Actually, it's better than C! As well as logical shifts, you have
circular (rotate) and arithmetic (sign-aware) shifts in Ada.




  reply	other threads:[~2003-10-19 17:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-15 17:42 Any examples of Byte Ordering Functions Bill Sheehan
2003-10-15 18:55 ` Larry Kilgallen
2003-10-15 18:44   ` Hyman Rosen
2003-10-16  1:01     ` James Rogers
2003-10-16 13:32       ` Hyman Rosen
2003-10-16 14:59       ` Martin Dowie
2003-10-16 20:00         ` tmoran
2003-10-17 12:08           ` Martin Dowie
2003-10-19 15:22         ` chris
2003-10-19 17:25           ` (see below) [this message]
2003-10-19 13:45     ` chris
2003-10-19 16:53       ` Martin Dowie
2003-10-19 17:52         ` chris
2003-10-19 19:24           ` Martin Dowie
2003-10-19 20:47           ` Jeffrey Carter
2003-10-19 22:53             ` tmoran
2003-10-20  4:14               ` Jeffrey Carter
2003-10-23 20:36       ` Laurent Pautet
2003-10-23 21:37         ` Simon Wright
2003-10-24  4:37           ` Simon Wright
2003-10-26 15:05           ` Georg Bauhaus
2003-10-23 20:44       ` Laurent Pautet
2003-10-23 21:03       ` Laurent Pautet
2003-10-15 19:58 ` Frank J. Lhota
2003-10-16 16:28 ` Stephen Leake
replies disabled

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