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 
Switch to threaded view of this topic Create a new topic Submit Reply
converting ieee-float-format to pw-wave-float-format [message #2655] Fri, 26 August 1994 01:07 Go to next message
SLAMECZKA is currently offline  SLAMECZKA
Messages: 4
Registered: August 1994
Junior Member
In <33ien2$17v@ncar.ucar.edu> caron@acd.ucar.edu writes:

> you need to examine the binary representation of floating points on the
> two machines you are using. If you say what the cpus are, perhaps someone
> here could tell you the representations.
>
> [snip]
>
> The nice thing about ieee is that its the same across all machines (is that
> true for its byte order also?).

The manual of the program (EDAS) I am using on my PC 386 says, that the
datas will be written binary to the harddrive. I copy this datas to my network
harddrive, start pw_wave 4.01 (Dec VAX), read the datas and all the values are
correct, exept the floating points.

The manual only says; that the float is a 4 Byte floating point (float in
"c", IEEE Format). Thats everything.

Now what is this IEEE format?
Which bits are the exponent, which are the mantisse and how to translate it
to pw_wave??

I hope for help
thanks
Michael
Re: converting ieee-float-format to pw-wave-float-format [message #2659 is a reply to message #2655] Thu, 25 August 1994 12:39 Go to previous messageGo to next message
grunes is currently offline  grunes
Messages: 68
Registered: September 1993
Member
In article <33ien2$17v@ncar.ucar.edu> caron@acd.ucar.edu (John Caron) writes:
> The nice thing about ieee is that its the same across all machines (is that
> true for its byte order also?).

No. IEEE does not define byte order--at least it is in oposite order
on PCs from the most common useage on most Unix Workstations (Suns,
SGIs,... -- but watch out for Dec Alpha, which someone told me use
backwards (least significant byte first, like the PC) byte order.

The easiest translation method is to read the data on someone's Sun,
print it out formatted, and send it as text!

One thing puzzles me: Most floating point numbers translate between
Suns and PCs simply throught BYTEORDER. But NAN values seem to
behave differently. Does anyone know why?
Mitchell R Grunes (grunes@imsy1.nrl.navy.mil)
Allied-Signal Technical Services
c/o Code 7230 Naval Research Lab
Re: converting ieee-float-format to pw-wave-float-format [message #2660 is a reply to message #2655] Thu, 25 August 1994 08:52 Go to previous messageGo to next message
caron is currently offline  caron
Messages: 16
Registered: May 1994
Junior Member
you need to examine the binary representation of floating points on the
two machines you are using. If you say what the cpus are, perhaps someone
here could tell you the representations.

I remember converting VAX 11/70 to Intel x86; only difference was byte order and
the exponent bias. if exponent bias differed by 2, that would give you a
factor of 4.

The nice thing about ieee is that its the same across all machines (is that
true for its byte order also?).
Re: converting ieee-float-format to pw-wave-float-format [message #2745 is a reply to message #2655] Fri, 26 August 1994 05:47 Go to previous messageGo to next message
grunes is currently offline  grunes
Messages: 68
Registered: September 1993
Member
In article <33k7s5$972@elna.ethz.ch> SLAMECZKA@EZINFO.VMSMAIL.ETHZ.CH (SLAMECZKA,MICHAEL) writes:
> Now what is this IEEE format?
> Which bits are the exponent, which are the mantisse and how to translate it
> to pw_wave??

Be clear on one thing: there is no IDL or PV-Wave floating point format,
when used with readu and writeu.

They use what ever is normal for their machines. i.e.--if you read it
back on the same computer that you wrote it on, everything would
be fine.

I don't recall the exact format, but on a MSB first machine I
believe the order is:
Sign Bit (NOT twos complement format)
Base 2 exponent, excess notation
Mantissa, with assumed (not present) leading 1 (except for true zero,
which is represented by all zero bits)

On your PC (a LSB first machine) the bytes (NOT the fields) are in
reversed order. Also: IEEE includes a variety of NANs to represent
overflows, underflows and undefined values.

If you experiment, you should be able determine how many bits of exponent
and mantissa work. I seem to remember about 11 exponent bits, which
would give about 32-1-11 mantissa bits (+ the assumed leading 1 bit).
Mitchell R Grunes (grunes@imsy1.nrl.navy.mil)
Allied-Signal Technical Services
c/o Code 7230 Naval Research Lab
Re: converting ieee-float-format to pw-wave-float-format [message #2749 is a reply to message #2659] Fri, 26 August 1994 07:44 Go to previous message
thompson is currently offline  thompson
Messages: 584
Registered: August 1991
Senior Member
grunes@imsy1.nrl.navy.mil (Mitchell R Grunes) writes:

> No. IEEE does not define byte order--at least it is in oposite order
> on PCs from the most common useage on most Unix Workstations (Suns,
> SGIs,... -- but watch out for Dec Alpha, which someone told me use
> backwards (least significant byte first, like the PC) byte order.

I've often seen the byte order with the most significant byte first, i.e.
that use on most Unix workstations, referred to as the "network" byte order.
Most interchange formats, such as FITS, which are meant to be transportable
from machine to machine, use that byte order.

> One thing puzzles me: Most floating point numbers translate between
> Suns and PCs simply throught BYTEORDER. But NAN values seem to
> behave differently. Does anyone know why?

If both machines follow the IEEE standard, then both should recognize the same
NaN values. However, many bit patterns can represent NaN. Perhaps the two
machines use a different *default* NaN value.

Bill Thompson
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 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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL vs PV-WAVE
Next Topic: ERDAS format conversion

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

Current Time: Wed Oct 08 19:51:01 PDT 2025

Total time taken to generate the page: 0.00541 seconds