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

Home » Public Forums » archive » Re: signed character
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: signed character [message #30412] Thu, 25 April 2002 06:24 Go to previous message
Mark Rivers is currently offline  Mark Rivers
Messages: 49
Registered: February 2000
Member
Carmen <cambicambi@hotmail.com> wrote in message
news:8128b197.0204250239.509a20fb@posting.google.com...
> Hello,
>
> I am trying to access information stored in a matrix, byte per byte.
> If I were using C, I should read every byte as SIGNED CHARACTERS.
> But, IDL has not that definition.
>
> I would appreciate a lot if you can tell me what should I do in order
> to read the data correctly.

If A is the matrix containing an IDL byte array (which IDL assumes is
unsigned) then you could do

; First convert A to a signed 16-bit integer array
a = fix(a)
; Find the indices of the negative elements (MSB of 8-bit value set)
negs = where(a and '80'x)
; Extended the sign to 16 bits
a[negs]=a[negs] or 'ff80'x

The drawbacks of this approach are that your matrix is twice as big (16 bits
vs 8 bits), and that you need to create the temporary array "negs". If your
matrix is only 2-D and not terribly huge then this should be fine.

Mark Rivers
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Reading F77 on Windows platforms
Next Topic: Re: Help me aviod a FOR loop!?!?

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

Current Time: Fri Oct 10 04:55:30 PDT 2025

Total time taken to generate the page: 0.63925 seconds