Re: Float procedure [message #13745 is a reply to message #13742] |
Wed, 02 December 1998 00:00   |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
Charlie Solomon wrote:
> Can anyone shed some light on how this byte array is converted into a
> floating point number?
> two_words = bytarr(4)
> two_words = [244, 232, 165, 64]
> IDL> print, two_words, format = '(z)'
> f4
> e8
> a5
> 40
> IDL> print, float(two_words, 0)
> 2.13062e-038
>
> On my computer at work (NT4, x86) I get a different value...5.18469
> Here at home (Win98, x86) I get this really small number....
> IDL> print, !version
> { x86 Win32 Windows 5.1.1 Jul 20 1998}
In addition to Alex Schuster's comments, the only suggestion I have is
to use the HELP routine to keep track of variable types, e.g.
IDL> two_words = bytarr(4)
IDL> help, two_words
TWO_WORDS BYTE = Array[4]
IDL> two_words = [244, 232, 165, 64]
IDL> help, two_words
TWO_WORDS INT = Array[4]
One of the most important things to learn in IDL programming is the
transient nature of variable types. Frequent use of HELP both on the
command line *and* within your IDL programs is a very effective way to
help ensure your IDL code works the way you intended.
Cheers,
Liam.
---
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
1225 W. Dayton St., Madison WI 53706, USA
Phone (608) 265-5358, Fax (608) 262-5974
http://cimss.ssec.wisc.edu/~gumley
|
|
|