|
Re: type conversion [message #43988 is a reply to message #43985] |
Fri, 06 May 2005 12:12  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
rensheu@yahoo.com writes:
> I have a question about type conversion in IDL.
>
> I get a float value return by IDLffDICOM object, but it is stored in
> byta[4]. Is there any way like in C as follows,
>
> char byta[4]={103, 38, 18, 68};
> float tmpv;
>
> pf = (float *)(&bytarr);
> tmpv = (float)(*pf);
>
> convert the varible from a 4 elements byte array to a float point
> variable in IDL?
Try this:
byta = [103B, 38B, 18B, 68B]
var = Float(byta, 0)
You need the offset (the second positional parameter), as
I just learned again this morning to my chagrin. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|