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

Home » Public Forums » archive » Re: Pack a Float into Bytes
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: Pack a Float into Bytes [message #76440 is a reply to message #76439] Thu, 02 June 2011 09:11 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Jun 2, 11:56 am, David Fanning <n...@idlcoyote.com> wrote:
> David Fanning writes:
>>> Is this what you mean?
>
>>> b = byte(!pi,0,4)  ;Convert !pi to a byte array
>>> print,float(b,0,1)  ;Convert back to a floating point number
>
>> Yes, that's what I mean. I was just getting on to write
>> a note that I found what I was looking for on my own
>> web page! (Not in such a nice, pithy two lines, though.)
>
>> I think I'll write this up for the future! :-)
>
> I wrote a short article that demonstrates how to do this
> with floating point arrays, the real topic of my inquiry
> this morning.
>
> http://www.idlcoyote.com/code_tips/packfloat.php

Of course, there are caveats. If you are exchanging bytes between
different kinds of computers, there is a risk that they will interpret
the bytes differently. For data exchange, judicious use of the
BYTEORDER with /XDRTOF and /FTOXDR are recommended.

Craig
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL 8 on a Laptop
Next Topic: Re: IDL 8 on a Laptop

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

Current Time: Wed Oct 08 20:08:30 PDT 2025

Total time taken to generate the page: 0.00164 seconds