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,1eda8da8a6221ea7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-17 19:43:31 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!news-hog.berkeley.edu!ucberkeley!enews.sgi.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: bitwise operations in Ada95 References: <9j2p76$6is$1@fang.dsto.defence.gov.au> X-Newsreader: Tom's custom newsreader Message-ID: Date: Wed, 18 Jul 2001 02:43:30 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 995424210 24.7.82.199 (Tue, 17 Jul 2001 19:43:30 PDT) NNTP-Posting-Date: Tue, 17 Jul 2001 19:43:30 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:10116 Date: 2001-07-18T02:43:30+00:00 List-Id: > Is there a way of performing bitwise operations on basic > types, e.g, integers, floats etc as in the bitwise and '&' and > bitwise or '|' in c. In Ada you can do logical operations on arrays of booleans. If space is a consideration you can use pragma pack. If that is the wrong abstraction, you do bitwise "and" and "or" on modular types, and you can convert integers to and from modular types if they have the same size and you don't get in trouble with the sign bit. This won't work in general for floating point types, clearly, so there you would have to use Unchecked_Conversion to and from a suitable modular type. If you are trying to mask the exponent or mantissa of a float, conversion to a suitable record, and then use of elements of the record, would probably be more appropriate. The general answer to "is there a way ... as in c" is yes, though perhaps not at the same abstraction level.