comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Convertion from binary string to 16bit integer
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Convertion from binary string to 16bit integer [message #56209 is a reply to message #56202] Mon, 15 October 2007 04:44 Go to previous messageGo to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Oct 15, 9:55 am, sjwelch <samjwe...@gmail.com> wrote:
> Long time reader, first time poster. Greetings to all.
>
> assuming you have a 16 character, left '0' padded string, strbin
>
> number = total((byte(strbin) - 48b) * (2L ^ reverse(bindgen(16))))
>
> that's what IDL does best ;) sure there's a simpler way too...
>
> On Oct 14, 8:21 pm, Tal <t...@bar-kal.com> wrote:
>
>> Hi guys,
>
>> Great help with this int2bin code from 2005 (1993):http://groups.google.com/group/comp.lang.idl-pvwave/b rowse_thread/thr...
>
>> Has anyone wrote an inverse code like bin2int or something equivalent?
>> It would be generally to sum up all products of 2^i values with the
>> corresponding 1's and 0's that a binary string has. (i=0,15 or 0,7 for
>> example).
>
>> The solution i'm looking for is for a 16bit binary string.
>
>> Cheers,
>> Tal

Hi

I may be barking completely up the wrong tree, but is this what you
want?

Arr = BYTE (BinaryString) - 48
Els = N_ELEMENTS (Arr)

Result = TOTAL (2^ LINDGEN (Els) * Arr )

all the best
Chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: for loop elimination
Next Topic: ENVI ROUTINES

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 10:35:05 PDT 2025

Total time taken to generate the page: 1.19976 seconds