From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ce2598d1b5ccf8c8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-18 01:22:16 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.com!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: crc and Ada Date: Sun, 18 May 2003 09:38:55 +0200 Organization: AdaCL Message-ID: <1333465.LIRSXZjOFg@linux1.krischik.com> References: Reply-To: martin@krischik.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8Bit X-Trace: news.t-online.com 1053246068 02 16883 odfWEzXESgYkz4 030518 08:21:08 X-Complaints-To: abuse@t-online.com X-ID: XcN9RTZUgeU0iY4Zc8fRvC5OZ4sap9S4Z0Xt3Dxbe42dEuxZXuJwcp User-Agent: KNode/0.7.2 Xref: archiver1.google.com comp.lang.ada:37472 Date: 2003-05-18T09:38:55+02:00 List-Id: 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