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

Home » Public Forums » archive » Re: Accessing bits in a floating point number
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: Accessing bits in a floating point number [message #10424] Fri, 21 November 1997 00:00 Go to previous message
Thomas A. McGlynn is currently offline  Thomas A. McGlynn
Messages: 23
Registered: March 1996
Junior Member
Brian Chafin wrote:
>
> I have a somewhat peculiar problem and would like to know if anyone has
> a solution for it.
>
> I am reading a 16-bit floating point number from an HDF file. This
> 16-bit number was originally two 1-byte integers which were stuffed into
> a 16-bit float. This was done in C and don't ask why it was done this
> way.
>
> When the float is read into IDL using the native IDL HDF commands, the
> result is a 32-bit float.
>
> Is there any way to extract the original two 1-byte integers from this
> IDL float?
>
> Thanks,
>
> Brian
>

You can convert the floats to a byte array and then look at the
bytes, e.g.,

myBytes = byte(myFloat,0, 4)

will make myBytes a byte array of dimension 4 with
the constituent bytes of myFloat. So assuming the
HDF routines converted it faithfully you can get the
two bytes back.

Hope this helps,
Tom McGlynn
[Message index]
 
Read Message
Read Message
Previous Topic: ION (IDL on Net) any remarks to it?
Next Topic: matlab conversion

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

Current Time: Fri Oct 10 14:33:53 PDT 2025

Total time taken to generate the page: 1.35921 seconds