comp.lang.ada
 help / color / mirror / Atom feed
From: "Stephen Frackelton" <stephen.frackelton@baesystems.com>
Subject: Re: Convert array to integer value
Date: Thu, 23 May 2002 16:27:31 +0100
Date: 2002-05-23T16:27:31+01:00	[thread overview]
Message-ID: <3ced0a3c$2@pull.gecm.com> (raw)
In-Reply-To: 3CED0420.5C5A9B6D@uk.thalesgroup.com

thanks, will consider this in future, but this would involve too many
changes now...

any others ?

"Nige" <nigel.scott@uk.thalesgroup.com> 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





  reply	other threads:[~2002-05-23 15:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-23 14:49 Convert array to integer value Stephen Frackelton
2002-05-23 15:00 ` Nige
2002-05-23 15:27   ` Stephen Frackelton [this message]
2002-05-23 16:36     ` Stephen Leake
2002-05-23 15:35 ` David Gillon
2002-05-24  8:22   ` Stuart Palin
  -- strict thread matches above, loose matches on Subject: below --
2002-05-23 16:49 Beard, Frank [Contractor]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox