Xref: utzoo comp.sys.dec:724 comp.os.vms:7539 Path: utzoo!attcan!uunet!husc6!mailrus!ames!ncar!acdpyr!pack From: pack@acdpyr.ucar.edu (Dan Packman) Newsgroups: comp.sys.dec,comp.os.vms Subject: Re: difference between vax floating point representation and IEEE Summary: IEEE floating point to/from VAX floating point Keywords: IEEE vax floating Message-ID: <471@ncar.ucar.edu> Date: 22 Jul 88 22:37:55 GMT References: <2256@hubcap.UUCP> Sender: news@ncar.ucar.edu Reply-To: pack@acdpyr.UCAR.EDU (Dan Packman) Organization: Atmospheric Chemistry Division/NCAR, Boulder CO Lines: 62 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