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

Home » Public Forums » archive » Please HELP!!!!!
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: Please HELP!!!!! [message #4948 is a reply to message #4866] Tue, 22 August 1995 00:00 Go to previous message
Mike Mathews is currently offline  Mike Mathews
Messages: 7
Registered: May 1995
Junior Member
phil@peace.med.ohio-state.edu (Phil) wrote:
> Howdy,
>
> I have a problem that is only loosely related to IDL that I hope one
> of you can help me out. I want to take the bytes from a 32-bit
> floating point number and determine the floating point value of it. I
> can do this in IDL by the following:
>
> IDL>a = bytarr(4)
> IDL>openw,1,'temp'
> IDL>writeu,1,160.0
> IDL>close,1
> IDL>openr,1,'temp'
> IDL>readu,1,a
> IDL>close,1
> IDL>print,float(a,0)
> 160.0
> IDL>print,a
> 67 32 0 0
>
> Now, here is the problem. I'm trying to get the same answer by hand
> and can't seem to do it. I have been doing all sorts of interations
> to get the sign, exponent and mantissa for this and nothing seems to
> work. I know this is simple, but I just seem to be missing something.
> Could one of you people out there humble me and show me what I am
> doing wrong.
>


Try the following for the 32bits

s eeeeeeee fffffffffffffffffffffff

msb lsb msb lsb

l/msb is least/most significant bit

if 0 < e < 255 then v = (-1)^s * [2^(e-127)] * (1.f)
if e = 0 and f <> 0 then v = (-1)^s * [2^(-126) ] * (0.f)
if e = 0 and f = 0 then v = (-1)^s * 0
if e = 255 and f = 0 then v = (-1)^s * inf
if e = 255 and f <> 0 then v = NaN (not a number)

I haven't check your numbers but I hope this helps

Mike

--------------- mailto:fskmjm@pukfsk.puk.ac.za --------------------
Antarctic Workgroup Potchefstroom University
Physics Department South Africa
--------------- http://www.puk.ac.za/fskdocs/ --------------------
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: hdf converter?
Next Topic: PVWAVE - widgets

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

Current Time: Fri Oct 10 03:57:57 PDT 2025

Total time taken to generate the page: 0.79927 seconds