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

Home » Public Forums » archive » Re: Float procedure
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: Float procedure [message #13747 is a reply to message #13742] Wed, 02 December 1998 00:00 Go to previous message
Alex Schuster is currently offline  Alex Schuster
Messages: 124
Registered: February 1997
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]

Caution! This statements creates an intarr(4). You could define
two_words this way:

IDL> two_words = [244b, 232b, 165b, 64b]

> IDL> print, float(two_words, 0)
> 2.13062e-038

I get this result:

IDL> f = float( two_words, 0 )
IDL> print, f
-1.47457e+32

This still isn't the value you expect, because your PC uses another byte
ordering scheme than my workstation. Changing this with the swap_endian
routine corrects this:

IDL> print, swap_endian( f )
5.18469


Alex
--
Alex Schuster Wonko@weird.cologne.de PGP Key available
alex@pet.mpin-koeln.mpg.de
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: ENVI ROI public code??
Next Topic: Re: 3D convolution

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

Current Time: Sat Oct 11 20:27:30 PDT 2025

Total time taken to generate the page: 1.19815 seconds