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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ded6ba3fc5b87b66 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-10-24 21:50:34 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!europa.netcrusader.net!205.252.116.205!howland.erols.net!news-xfer.netaxs.com.MISMATCH!news-xfer.newsread.com!bad-news.newsread.com!netaxs.com!newsread.com!POSTED.newshog.newsread.com!not-for-mail Message-ID: <3A46E0A5.6C9EC5FD@telepath.com> From: Ted Dennison X-Mailer: Mozilla 4.72 [en] (Windows NT 5.0; I) X-Accept-Language: en,pdf MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: First time Ada has let me down References: <8FD7DEBEEsynoptikdamudderfuck@news> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 25 Oct 2000 04:50:17 GMT NNTP-Posting-Host: 38.195.186.125 X-Complaints-To: Abuse Role , We Care X-Trace: newshog.newsread.com 972449417 38.195.186.125 (Wed, 25 Oct 2000 00:50:17 EDT) NNTP-Posting-Date: Wed, 25 Oct 2000 00:50:17 EDT Organization: Telepath Systems (telepath.com) Xref: supernews.google.com comp.lang.ada:1538 Date: 2000-10-25T04:50:17+00:00 List-Id: Note to new posters: Always state up front that you are using Ada 83. Its an obsolete standard, so most folks here will assume you are using Ada 95 unless you say otherwise. Shifty wrote: > This stumped me for awhile, but then I went home and picked up a C book. > Hmmm, chapter 15 - bit fiddling. I learned a bunch of stuff about masks > and bitwise operators and came up with a working solution. (which seems > much better than using record representation clauses and typecasting a 4 > bit value into an 8 bit integer) "typecasting"? No such thing in Ada. Integer types are convertable to each other, but that's a simple operation that generates *no* code (except sometimes a range check, which you can disable if you need to). A record rep clause does seem a good way to go, but there are probably others. > Next morning I tried to implement the solution and couldn't find the Ada > equivalent of C's bit-wise & operater. According to my "Ada as a 2nd > language" book, the Ada reserved word "AND" only works for boolean types, > not integer types. I got the impression that it was up to the programmer > to write his own bitwise ANDs/ORs/XORs, etc (it wouldn't be hard). It also works for modular integer types (Ada95 only) and *arrays* of booleans (which can be packed). Either one will do what you want. But if you also want to work with the data as integers, its silly to do it this way, then have to Unchecked_Convert all over the place. Let the record rep clause do the work for you! -- T.E.D. Home - mailto:dennison@telepath.com Work - mailto:dennison@ssd.fsi.com WWW - http://www.telepath.com/dennison/Ted/TED.html ICQ - 10545591