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

Home » Public Forums » archive » Re: BYTES to LONG
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: BYTES to LONG [message #22337 is a reply to message #22334] Tue, 07 November 2000 00:00 Go to previous messageGo to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
Paul van Delst wrote:
>
> Kelly Dean wrote:
>>
>> I am reading in a combination ASCII/BINARY file with USGS DLG
>> information as a binary file.
>>
>> I am able to convert the bytes into ASCII with STRING([72B, 101B, 108B,
>> 108B, 111B]).
>>
>> However, I cannot figure out how to convert the 4 bytes into LONG, whihc
>> is the UTM X and Y numbers. Any suggestions?
>>
>> Kelly
>
> If I understand your question correctly,
>
> if
>
> x = [ 0B, 1B, 1B, 1B ]
>
> then long_x = TOTAL( ISHFT( LONG(x), [24,16,8,0] ) )
>
> ??
>
> This gave me long_x = 65793.0 = 65536 + 256 + 1 which seems correct, no?
>
> For some reason the TOTAL returned a floating point number? Weird. Never noticed that
> before.
>

The total() function always converts to floating point before the sum,
to avoid overflow issues. Consider:

a=total(bindgen(256))

if it did the total as bytes, that would overflow. Of course, it could
have done them as regular ints, but how should it decide, a priori? I
for one use total a lot in testing various conditions, and it always
bothered me that I had to test the floating result, but there's really
no other clean solution.

JD

--
J.D. Smith | WORK: (607) 255-6263
Cornell Dept. of Astronomy | (607) 255-5842
304 Space Sciences Bldg. | FAX: (607) 255-5875
Ithaca, NY 14853 |
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Electrical Engineer/Controls Specialist Wanted
Next Topic: Re: UTM conversion

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

Current Time: Fri Oct 10 20:11:16 PDT 2025

Total time taken to generate the page: 0.72580 seconds