[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BYTES to LONG
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?
If I understand your question correctly,
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
You could also just add the requisite power of two to each individual element before
totaling also. Dunno if either works with a sign bit.
Paul van Delst Ph: (301) 763-8000 x7274
CIMSS @ NOAA/NCEP Fax: (301) 763-8545
Rm.207, 5200 Auth Rd. Email: email@example.com
Camp Springs MD 20746