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,95db39b88fd27b40 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-23 07:58:09 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.tele.dk!small.news.tele.dk!130.240.42.8!luth.se!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!news!not-for-mail From: Nige Newsgroups: comp.lang.ada Subject: Re: Convert array to integer value Date: Thu, 23 May 2002 16:00:48 +0100 Organization: Thales Message-ID: <3CED0420.5C5A9B6D@uk.thalesgroup.com> References: <3ced014d$1@pull.gecm.com> NNTP-Posting-Host: 172.21.150.55 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: rdel.co.uk 1022165887 20118 172.21.150.55 (23 May 2002 14:58:07 GMT) X-Complaints-To: postmaster@uk.thalesgroup.com NNTP-Posting-Date: 23 May 2002 14:58:07 GMT X-Mailer: Mozilla 4.77 [en] (X11; U; SunOS 5.6 sun4m) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:24579 Date: 2002-05-23T14:58:07+00:00 List-Id: Stephen Frackelton wrote: > > I have set up an array of integers, value 0..1, to simulate a word, 16 bits. > > I need to convert this array of 0's and 1's from the binary value to its > corresponding integer value. > > is there any simple way of doing this ? > > All i can think of is for loop through the array and having a translation > table for each position within the array, i.e if bit 5 = 1 then add 16 to > total, if bit 6 = 1 then add 32 to total and so on. > > any other ideas ? If you make it an array of booleans, you can pack the array into 16 bits, then do an unchecked conversion into an unsigned_16 on the array... Also, a boolean array will allow you to do logical operations too... Nige