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 #78602 is a reply to message #78595] Wed, 07 December 2011 05:19 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Lajos Foldy writes:

> 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

You may have missed this in Lejos's explanation, but
all of these "casting" functions (e.g., Fix, Long, Float,
etc.) can extract data from byte arrays in this fashion.
And not just one value at a time, but all the values
at once. The trick is to use the offset parameter to
tell the function how may byte values to "grab" when
it does the conversion.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[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: Thu Oct 09 08:36:48 PDT 2025

Total time taken to generate the page: 2.40740 seconds