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

Home » Public Forums » archive » Reading 32-bit complex numbers in IDL (16-bit real / 16-bit imaginary)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Reading 32-bit complex numbers in IDL (16-bit real / 16-bit imaginary) [message #77117] Sun, 07 August 2011 05:01 Go to next message
Waqas A. Qazi is currently offline  Waqas A. Qazi
Messages: 3
Registered: August 2011
Junior Member
Hi,

I couldn't find a discussion of this specific problem on the group, so
I am posting it here in hope of a solution.

I have complex data in a binary file, with each value comprising of 4
bytes (32 bits), such that the 32-bit complex number consists of 16-
bit real and 16-bit imaginary. I could use define a complex array in
IDL and then read the data using the readu command, however the
"complex" format in IDL is a 2*32-bit definition, i.e. 32-bit real and
32-bit imaginary. How can I read the 16-bit real - 16-bit imaginary
complex number in IDL?


Thanks,
Waqas.
Re: Reading 32-bit complex numbers in IDL (16-bit real / 16-bit imaginary) [message #77232 is a reply to message #77117] Mon, 15 August 2011 10:58 Go to previous message
Waqas A. Qazi is currently offline  Waqas A. Qazi
Messages: 3
Registered: August 2011
Junior Member
On Aug 13, 6:26 am, Wox <s...@nomail.com> wrote:

> When I say "convert integer to float" I don't mean that you would
> convert 10 to 10.0 for example. The value of the integer is not
> concidered at all, it's the "bit-content" that is used. The integer is
> just a bag of bits that represent a foating point number according to
> the IEEE754 standard. That's why the function is call BINARYTOFLOAT
> and not INTEGERTOFLOAT or something. In the example I gave:
>
> IDL> integer='3555'x
> IDL> f=binarytofloat(integer,precision=0)
> IDL> print,integer
>    13653
> IDL> print,f
>      0.333252
>
> You can see that the integer value 13653 has nothing to do with
> 0.33325... However both numbers have the same binary representation,
> namely
>
> IDL> print,integer,format='(b016)'
> 0011010101010101
>
> Note: Since IDL can't handle 16bit floats, the binary representation
> of f (32bit float) isn't the same anymore as that of 13653. The value
> of f is correct however: the value represented by 13653 under the
> half-precision IEEE 754 convention.


Great, thanks Wox, I understand now.

For the specific data I am working with, its not half-precision per
se, because the 2-byte binary numbers are defined as integers, not
floats. So after reading the 2-byte integers from the binary file, I
will not need to convert to any float. I can read each alternating 2-
byte integer into separate real and imaginary part arrays, and then
input these two arrays directly into the complex function (data type
converter) in IDL.


Thanks,
Waqas.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: TITLE property using object graphics
Next Topic: IDL on Mac OS X 10.7 (Lion)

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

Current Time: Wed Oct 08 15:11:00 PDT 2025

Total time taken to generate the page: 0.00490 seconds