comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: crc and Ada
Date: Sun, 18 May 2003 09:38:55 +0200
Date: 2003-05-18T09:38:55+02:00	[thread overview]
Message-ID: <1333465.LIRSXZjOFg@linux1.krischik.com> (raw)
In-Reply-To: slrnbcec3j.rh.swierczu@staticline881.toya.net.pl

Bart?omiej ?. wrote:

> Hello,

> What I should use instand of 'xor' and 'and' oparator (becouse in Ada
> they are logical oparator, not binary).

"xor" and "and" are not only boolean  operators. They can be used with
several datatypes. Also you can also define your own "xor" and "and"
operators.

> For example, I replace crc<<8 by
> crc*256, and crc>>8 crc/256, but what about xor?

I belive that in your case (crc calculation) a modular datatype (which have
predefined "xor", "and", "or" and "not" operators) might be alternative.
i.E.

type Unsigned_Byte is mod 2**8;
type Unsigned_Short is mod 2**16;
type Unsigned_Long is mod 2**32;

you might want to add a representation clause (if you don't trust the
compiler to make the right choice):

for Unsigned_Byte'Size use 8;
for Unsigned_Short'Size use 16;
for Unsigned_Long'Size use 32;

Remember that for a modular type wrap arount arithmetic (which for a CRC
calculation is probably what you want) is used. i.E.

Zero_Byte : Unsigned_Byte := 255 + 1;

Disclainer: This might not compile, it's just to show the general idea.

With Regarda

Martin

 
> --
> Best regards,         PGP: http://wilk.wpk.p.lodz.pl/swierczu/pgp
> Bartek.               http://sknauk.wpk.p.lodz.pl

-- 
--
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




  parent reply	other threads:[~2003-05-18  7:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-18  7:04 crc and Ada Bartłomiej Ś.
2003-05-18  7:27 ` John R. Strohm
2003-05-18  7:38 ` Martin Krischik [this message]
2003-05-18  7:49 ` Martin Dowie
2003-05-18  7:56 ` tmoran
2003-05-18  9:35   ` Bartłomiej Ś.
2003-05-18  8:05 ` Tarjei T. Jensen
2003-05-19  9:09 ` Ludovic Brenta
replies disabled

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