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

Home » Public Forums » archive » converting ieee-float-format to pw-wave-float-format
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: converting ieee-float-format to pw-wave-float-format [message #2751 is a reply to message #2660] Fri, 26 August 1994 06:51 Go to previous messageGo to previous message
grunes is currently offline  grunes
Messages: 68
Registered: September 1993
Member
I was wrong: 8 bit exponent.

If you understand Fortran, these routines, which haven't been
completely tested, might help:


c-----------------------------------------------------
function FromVaxR4(x)
c Function to convert Vax real*4 number to local floating point.
c Cannot handle NANs or numbers which are too small or too large.
c By mitchell r grunes.
integer*4 x,y,i ! Really Vax real*4--but
! must be kept in integers
! so won't be "normalized".
character*1 a(4)
equivalence (y,a)
parameter (Mask23=2**23-1)
parameter (ioffset=128+24)

y=x
i= iand(ichar(a(2)),255)
i=ior(ishft(i,8),iand(ichar(a(1)),255))
i=ior(ishft(i,8),iand(ichar(a(4)),255))
i=ior(ishft(i,8),iand(ichar(a(3)),255))

iexponent=iand(ishft(i,-23),255)-ioffset
mantissa=iand(i,Mask23)

if(i.eq.0)then
FromVaxR4=0
else
mantissa=ior(ishft(1,23),mantissa)
if(i.gt.0)then
FromVaxR4= mantissa*2.**iexponent
else
FromVaxR4=-mantissa*2.**iexponent
endif
endif
end
c-----------------------------------------------------
function FromIEEER4(x)
c Function to convert IEEE real*4 number to local floating point.
c Assumes number written on a "most significant byte first" machine like
c a Sun or SGI workstation.
c Cannot handle NANs or numbers which are too small or too large.
c By mitchell r grunes.
integer*4 x,y,i ! Really IEEE real*4--but
! must be kept in integers
! so won't be "normalized".
character*1 a(4)
equivalence (y,a)
parameter (Mask23=2**23-1)
parameter (ioffset=128+22)

y=x
i= iand(ichar(a(1)),255)
i=ior(ishft(i,8),iand(ichar(a(2)),255))
i=ior(ishft(i,8),iand(ichar(a(3)),255))
i=ior(ishft(i,8),iand(ichar(a(4)),255))

iexponent=iand(ishft(i,-23),255)-ioffset
mantissa=iand(i,Mask23)

if(i.eq.0)then
FromIEEER4=0
else
mantissa=ior(ishft(1,23),mantissa)
if(i.gt.0)then
FromIEEER4= mantissa*2.**iexponent
else
FromIEEER4=-mantissa*2.**iexponent
endif
endif
end
c-----------------------------------------------------
function FromRIEEER4(x)
c Function to convert IEEE real*4 number to local floating point.
c Assumes number written on a "least significant byte first" machine like
c a PC.
c Cannot handle NANs or numbers which are too small or too large.
c By mitchell r grunes.
integer*4 x,y,i ! Really IEEE real*4--but
! must be kept in integers
! so won't be "normalized".
character*1 a(4)
equivalence (y,a)
parameter (Mask23=2**23-1)
parameter (ioffset=128+22)

y=x
i= iand(ichar(a(4)),255)
i=ior(ishft(i,8),iand(ichar(a(3)),255))
i=ior(ishft(i,8),iand(ichar(a(2)),255))
i=ior(ishft(i,8),iand(ichar(a(1)),255))

iexponent=iand(ishft(i,-23),255)-ioffset
mantissa=iand(i,Mask23)

if(i.eq.0)then
FromRIEEER4=0
else
mantissa=ior(ishft(1,23),mantissa)
if(i.gt.0)then
FromRIEEER4= mantissa*2.**iexponent
else
FromRIEEER4=-mantissa*2.**iexponent
endif
endif
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL vs PV-WAVE
Next Topic: ERDAS format conversion

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

Current Time: Sun Oct 12 08:28:13 PDT 2025

Total time taken to generate the page: 1.60431 seconds