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

Home » Public Forums » archive » Re: Constructing integer variables from two bytes?
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: Constructing integer variables from two bytes? [message #78603 is a reply to message #78602] Wed, 07 December 2011 04:52 Go to previous message
Lajos Foldy is currently offline  Lajos Foldy
Messages: 176
Registered: December 2011
Senior Member
On Dec 7, 6:46 am, Jared Espley <jesp...@gmail.com> wrote:
> I have data in a byte array that I would like to use to construct
> arrays of unsigned integers and integers.
>
> In code:
> A = [1B, 2B]
> B = 0
> B = A[0]*256 + fix(A[1])
>
> Which will give B as an integer type with a value 258.
>
> I realize that I can construct functions to do this (multiple each bit
> by the appropriate value and checking which OS we're in so that we get
> endianness correct) but I was wondering if someone had already done
> this rigorously?
>
> Thanks,
> Jared

FIX can combine the bytes into integers (in host byte order, use
SWAP_ENDIAN if the source byte order is different):

IDL> b2=fix(a, 0, 1, type=2)
IDL> help, b2
B2 INT = Array[1]
IDL> print, b2
513
IDL> print, swap_endian(b2)
258

regards,
Lajos
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Coyote Graphics PDF Files
Next Topic: IDLDOC question

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

Current Time: Fri Oct 10 02:39:05 PDT 2025

Total time taken to generate the page: 2.39134 seconds