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.7 required=5.0 tests=BAYES_00,MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fb4f2a91d58d3a,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-09-08 16:40:09 PST Path: supernews.google.com!sn-xit-02!sn-east!supernews.com!news-feed.riddles.org.uk!nntp.cs.ubc.ca!news.ksw.feedmania.org!newsfeed.media.kyoto-u.ac.jp!Q.T.Honey!news.join.ad.jp!newsfeed.mathworks.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: ebresie@usa.net Newsgroups: comp.lang.ada Subject: Bit operations in Ada (one's complements and sum) Date: Fri, 08 Sep 2000 23:34:03 GMT Organization: Deja.com - Before you buy. Message-ID: <8pbt1a$vo8$1@nnrp1.deja.com> NNTP-Posting-Host: 129.116.78.131 X-Article-Creation-Date: Fri Sep 08 23:34:03 2000 GMT X-Http-User-Agent: Mozilla/4.74 [en] (WinNT; U) X-Http-Proxy: 1.0 x70.deja.com:80 (Squid/1.1.22) for client 129.116.136.159, 129.116.78.131 X-MyDeja-Info: XMYDJUIDebresie Xref: supernews.google.com comp.lang.ada:550 Date: 2000-09-08T23:34:03+00:00 List-Id: I am curious if there exists either built in or already developed somewhere, a bit manipulation package. I am trying to have 16-bit numbers that are made into one's complement and have one's complement summation occur with the values. I started working on some of it, but thought I would check to see if maybe this functionality already exists somewhere in ADA95 or exists somewhere (one of the things about ADA is reusablility right :-) I am not an expert of package development so any help would be appreciated. I started thinking that I would have something along the lines of: package Bits is -- I was thinking of using an array of Booleans but wasn't sure if this -- was the most efficient way of working with Bits. type BIT_String is new String; type Ones_Complement is new BIT_String; type Twos_Complement is new BIT_String; function Ones_Complement( N : Integer ) return BIT_String; function Twos_Complement( N : Integer ) return BIT_String; function "+"( Left: Ones_Complement; Right : Twos_Complement ) return Ones_Complement; function "+"( Left: Twos_Complement; Right : Twos_Complement ) return Twos_Complement; end Bits The implementation I haven't completed yet...but figured I would check with you guys first. The implementation basically would take the Integer, check for negative value, store a 1 for negative/0 for postive, then div/mod by two to get each bit place. I guess I should be able to somehow make this seperate from the data type Integer and make it more abstract...how is the best way to do that? I am I just making this harder then I need to? Any help would be appreciated Eric Bresie ebresie@usa.net Sent via Deja.com http://www.deja.com/ Before you buy.