From:	CSBVAX::MRGATE!info-vax-RELAY@KL.SRI.COM@SMTP 28-JUL-1988 12:13
To:	ARISIA::EVERHART
Subj:	Re: difference between vax floating point representation and IEEE


Received: from ucbvax.berkeley.edu by KL.SRI.COM with TCP; Fri, 22 Jul 88 20:43:38 PDT
Received: by ucbvax.berkeley.edu (5.59/1.28)
	id AA01801; Fri, 22 Jul 88 17:14:08 PDT
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 22 Jul 88 22:37:55 GMT
From: acdpyr!pack@handies.ucar.edu  (Dan Packman)
Organization: Atmospheric Chemistry Division/NCAR, Boulder CO
Subject: Re: difference between vax floating point representation and IEEE
Message-Id: <471@ncar.ucar.edu>
References: <2256@hubcap.UUCP>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <2256@hubcap.UUCP> ghosh@hubcap.UUCP (Amitava Ghosh) writes:
>does anyone know what the difference is between the IEEE floating
>point representation and the way the VAX stores numbers. If so
>how does one convert from one format to the other...
The following program converts from vax f format to IEEE (UNIX point of view)
--------cut here-------------
      subroutine vax2lcl(n,iarray)
      dimension iarray(n)
      character*1 conv(4),ccc
      integer iconv
      equivalence (iconv,conv)
c Convert from vax floating point f format to pyramid IEEE single
      do 10 i=1,n
        iconv=iarray(i)
        if (iconv.ne.0) then
         ccc=conv(1)
         iii=ichar(conv(2))-1
         if (iii.lt.0)then
           write(0,100)iconv
 100       format(' vax2lcl: overflow int in =',i10)
           call exit(1)
         endif
         conv(1)=char(iii)
         conv(2)=ccc
         ccc=conv(3)
         conv(3)=conv(4)
         conv(4)=ccc
         iarray(i)=iconv
        endif
  10  continue
      return
      end
--------cut here-------------
The following converts an array of IEEE single floats to vax floats
It is written to work on a VAX/VMS machine
--------cut here-------------
      subroutine pyr2lcl(n,iarray)
      dimension iarray(n)
      byte conv(4),ccc
      integer iconv
      equivalence (iconv,conv)
c Convert from pyramid IEEE single to vax floating point f format
      do 10 i=1,n
        iconv=iarray(i)
        if (iconv.ne.0) then
         ccc=conv(2)
         iii=conv(1)+1
         if (iii.gt.255)then
           write(0,100)iconv
 100       format(' pyr2lcl: overflow int in =',i10)
           call exit(1)
         endif
         conv(2)=iii
         conv(1)=ccc
         ccc=conv(3)
         conv(3)=conv(4)
         conv(4)=ccc
         iarray(i)=iconv
        endif
  10  continue
      return
      end
