| Re: Help: C & IDL [message #14824] |
Fri, 26 March 1999 00:00 |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
Tri VU KHAC wrote:
> I want to read a binary file created by a C program. This data is a serie of
> unsigned short numbers (unsigned 2-byte) taking values from 0 to 64000.
> The problem is I don't find out the same type in ILD which enables me to
> read the unsigned 2-byte number.
If you are using IDL 5.2, then unsigned short integers are supported by
the UINT type, e.g.
help, 0U
help, uint(0)
help, uintarr(256,256)
If you are using IDL 5.1 or earlier, first read the data into an INT
(signed short integer) array. Then to extract unsigned short integers,
convert to LONG and perform a bitwise AND with the LONG value 65535
(that is, bits 0-15), e.g.
for i = -5, 5 do help, (long(i) and 65535L)
Cheers,
Liam.
---
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
|
|
|
|