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.3 required=5.0 tests=BAYES_00,INVALID_MSGID, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8309f2bc055237c4 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Bit manipulation Date: 2000/11/08 Message-ID: <8ubeq8$cgm$1@nnrp1.deja.com>#1/1 X-Deja-AN: 691162502 References: <8u8v6n$b7o$1@nnrp1.deja.com> <2WTH$pdrCfOd@eisner.decus.org> <8ub6kt$6nd$1@nnrp1.deja.com> X-Http-Proxy: 1.0 x54.deja.com:80 (Squid/1.1.22) for client 129.37.79.144 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed Nov 08 11:52:42 2000 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; I) Date: 2000-11-08T00:00:00+00:00 List-Id: In article <8ub6kt$6nd$1@nnrp1.deja.com>, gdemont@my-deja.com wrote: > But: > "Which way may I shift bits, or mask them?" > > And your hint about using records, arrays and representation > clauses is completely overkill just for blipping bits! Please > give constructive answers! Nope! When someone asks how can I do "xxx" and xxx is a low level implementation technique, it is always appropriate to enquire as to what the problem is. A C programmer is used to shifting and masking as a solution for all sorts of problems. Now there are cases where such a solution is appropriate in Ada, which is why the capability was added in Ada 95, but compared to C, they are few and far between. Clearly the underlying question is "how do I do shifts and masks to achieve xxx", and to accurately answer this question we need to ask what xxx is. Quite likely the answer will be "don't use shifts and masks to achieve xxx if you are writing Ada, instead use yyy". Of course we could give a simple answer involving the obvious solution of converting Character'Pos values to a modular type and then doing shifts and masks in the normal manner, but that would be a disservice. I see a *lot* of code that is clearly written by C programmers and greatly overuses low level bit twiddling techniques that are appropriate to C but not to Ada. If someone simply wants to get a job done in the dirtiest possible fashion, and wants someone else to do the work, CLA is not the place to expect free help :-) Sent via Deja.com http://www.deja.com/ Before you buy.