Re: integer? [message #31577] |
Fri, 02 August 2002 02:01 |
Nigel Wade
Messages: 286 Registered: March 1998
|
Senior Member |
|
|
tom wrote:
> I am sorry for that.
> But only after read the answers, I try to replace XDR by ENDIAN... Then I
> find the problem.
>
Does the file actually contain XDR data?
If you write a short integer (16 bits) with xdr_short, the routine actually
writes 32 bits, big endian, to the data file (it only deals in multiples of
4 bytes in big endian, or network byte order).
--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
|
|
|
Re: integer? [message #31578 is a reply to message #31577] |
Thu, 01 August 2002 18:07  |
tom
Messages: 28 Registered: April 1995
|
Junior Member |
|
|
I am sorry for that.
But only after read the answers, I try to replace XDR by ENDIAN... Then I
find the problem.
"Nigel Wade" <nmw@ion.le.ac.uk> ??????:ai8ogm$1i4t$1@rook.le.ac.uk...
> tom wrote:
>
>> I know that. That because I use /xdr in open.
>>
>> Thanks.
>>
>>
>
> You might have mentioned that in your original post.
> AFAIK XDR doesn't have a 16 bit integer.
>
> Anything else you'd care to tell us about?
>
> --
> -----------------------------------------------------------
> Nigel Wade, System Administrator, Space Plasma Physics Group,
> University of Leicester, Leicester, LE1 7RH, UK
> E-mail : nmw@ion.le.ac.uk
> Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
|
|
|
Re: integer? [message #31615 is a reply to message #31578] |
Wed, 31 July 2002 06:56  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Nigel Wade (nmw@ion.le.ac.uk) writes:
> You might have mentioned that in your original post.
> AFAIK XDR doesn't have a 16 bit integer.
>
> Anything else you'd care to tell us about?
Maybe I'll work on that "Art of Asking a Question"
article some more today. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: integer? [message #31618 is a reply to message #31615] |
Wed, 31 July 2002 06:25  |
Nigel Wade
Messages: 286 Registered: March 1998
|
Senior Member |
|
|
tom wrote:
> I know that. That because I use /xdr in open.
>
> Thanks.
>
>
You might have mentioned that in your original post.
AFAIK XDR doesn't have a 16 bit integer.
Anything else you'd care to tell us about?
--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
|
|
|
Re: integer? [message #31620 is a reply to message #31618] |
Wed, 31 July 2002 05:26  |
tom
Messages: 28 Registered: April 1995
|
Junior Member |
|
|
I know that. That because I use /xdr in open.
Thanks.
On Wed, 31 Jul 2002 09:32:37 +0100, Nigel Wade <nmw@ion.le.ac.uk>
wrote:
> tom wrote:
>
>> Hi, all
>>
>> This is a segment of HEX: 00 00 00 64
>>
>> there are two 2byte-integers in it.
>> But when I set
>> a=0
>> readu,lun,a ; I hope a=hex(00 00)
>> print,a
>> the result is 100. That's a=hex(00 00 00 64)
>> that's the same as "a=0l readu,lun,a"
>>
>> how to read 2byte integer then?
>>
>> Tom
>
> Could the number be one little endian 32 bit integer rather than two 16 bit
> ones? That would account for the discrepancy.
>
> What platform are you doing this on, and what platform was the data file
> created on?
|
|
|
Re: integer? [message #31622 is a reply to message #31620] |
Wed, 31 July 2002 01:32  |
Nigel Wade
Messages: 286 Registered: March 1998
|
Senior Member |
|
|
tom wrote:
> Hi, all
>
> This is a segment of HEX: 00 00 00 64
>
> there are two 2byte-integers in it.
> But when I set
> a=0
> readu,lun,a ; I hope a=hex(00 00)
> print,a
> the result is 100. That's a=hex(00 00 00 64)
> that's the same as "a=0l readu,lun,a"
>
> how to read 2byte integer then?
>
> Tom
Could the number be one little endian 32 bit integer rather than two 16 bit
ones? That would account for the discrepancy.
What platform are you doing this on, and what platform was the data file
created on?
--
-----------------------------------------------------------
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523568, Fax : +44 (0)116 2523555
|
|
|
Re: integer? [message #31628 is a reply to message #31622] |
Tue, 30 July 2002 08:34  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
tom (tom2959@21cn.com) writes:
> This is a segment of HEX: 00 00 00 64
>
> there are two 2byte-integers in it.
> But when I set
> a=0
> readu,lun,a ; I hope a=hex(00 00)
> print,a
> the result is 100. That's a=hex(00 00 00 64)
> that's the same as "a=0l readu,lun,a"
>
> how to read 2byte integer then?
Like this:
IDL> a = '00000064'x
IDL> HELP, a
A INT = 100
IDL> Print, 'High order byte: ', Byte(a, 1)
High order byte: 0
IDL> Print, 'Low order byte: ', Byte(a, 0)
Low order byte: 100
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|