Routine to convert between IEEE and VAX floating point ?

Doug Tody CCS tody at noao.edu
Sun Jun 3 18:46:02 AEST 1990


>From article <1023 at rna.UUCP>, by dan at rna.UUCP (Dan Ts'o):
> 
> 	Does anyone have a C routine to convert from IEEE floating point
> to VAX D format floating point ?

This depends upon what cpu you want to perform the conversion on.  If you
want to convert to or from IEEE on a VAX cpu then I have some VAX assembler
routines which can do this (more efficiently than in C, due to the need to
bit shift a 64 bit quantity).

> 	Failing that or anything similar, does anyone have a concise
> description of the IEEE floating point format so I can write my own routine...

The main reference is the IEEE floating standard document.  I don't have the
document number handy, but you can order it from IEEE.  An IEEE double is
64 bits like a VAX D double, but the exponent is 11 bits rather than 8 for
VAX D format (VAX G format is also 11 bits), there is a *4 (or /4) factor
due to a difference in the normalization of the mantissa, and the bytes are
spped.

Converting IEEE single to VAX F is much simpler, all you do is byte swap and
multiply or divide by 4.0.

-- 
Doug Tody, National Optical Astronomy Observatories, Tucson AZ, 602-325-9217
UUCP: {arizona,decvax,ncar}!noao!tody  or  uunet!noao.edu!tody 
Internet: tody at noao.edu             SPAN/HEPNET: NOAO::TODY (NOAO=5355)



More information about the Comp.unix.ultrix mailing list