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

Home » Public Forums » archive » Re: Unsigned Integers - How?
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: Unsigned Integers - How? [message #8121 is a reply to message #8115] Fri, 07 February 1997 00:00 Go to previous messageGo to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
David Fanning wrote:
>
> Peter Berdeklis <peter@atmosp.physics.utoronto.ca> writes:
>
>> I'm trying to read a binary data file into IDL. Included in the data
>> headers are several unsigned integers for dates and times. Some of the
>> unsinged integers are overflowing, giving me negative integers. How do I
>> specify a variable as an unsinged integer in IDL?
>
> It's deja vu all over again, as one of our famous baseball players once
> said. :-)
>
> Read the unsinged integers into *signed* 16-bit integers in IDL.
> (You are already doing this, apparently).
>
> date = 0L
> time = 0L
> READU, lun, datafile, date, time
>
> Convert them to the correct *unsigned* values, like this:
>
> date = LONG(date) AND 'FFFF'x
> time = LONG(time) AND 'FFFF'x
>

Oops! If you specify LONG then you get 32-bit integers. So:

date = fix(0)
time = fix(0)
readu, lun, datafile, date, time

date = date AND 'FFFF'x
time = time AND 'FFFF'x

Of course, if you want 32-bit integers, use LONG like Dave suggested.

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
[ UCSD Mail Code 0949 ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: UNsigned Integer Data
Next Topic: Re: IDL 5.0 news at RSI website *correction*

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

Current Time: Fri Oct 10 00:43:30 PDT 2025

Total time taken to generate the page: 7.04337 seconds