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 08:27:35 PST From: "Stephen Frackelton" Newsgroups: comp.lang.ada References: <3ced014d$1@pull.gecm.com> <3CED0420.5C5A9B6D@uk.thalesgroup.com> Subject: Re: Convert array to integer value Date: Thu, 23 May 2002 16:27:31 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 NNTP-Posting-Host: waec3223.wa.bae.co.uk Message-ID: <3ced0a3c$2@pull.gecm.com> X-Trace: pull.gecm.com 1022167612 waec3223.wa.bae.co.uk (23 May 2002 16:26:52 +0100) Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!colt.net!newspeer.clara.net!news.clara.net!btnet-peer!btnet-peer0!btnet-feed3!btnet!newreader.ukcore.bt.net!pull.gecm.com!not-for-mail Xref: archiver1.google.com comp.lang.ada:24583 Date: 2002-05-23T16:27:31+01:00 List-Id: thanks, will consider this in future, but this would involve too many changes now... any others ? "Nige" wrote in message news:3CED0420.5C5A9B6D@uk.thalesgroup.com... > 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