Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* VAX double-precision format
@ 1995-06-30  4:00 Mike Unverferth
  1995-07-02  4:00 ` Peter Sherwood
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Unverferth @ 1995-06-30  4:00 UTC (permalink / raw)


I have some data files containing values in VAX double-precision.
I need to convert these values to Intel (IEEE) floating-point.
Can someone provide the format and/or C code to do the conversion?

--
Mike Unverferth
MicroImages, Inc.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: VAX double-precision format
  1995-06-30  4:00 VAX double-precision format Mike Unverferth
@ 1995-07-02  4:00 ` Peter Sherwood
  1995-07-03  4:00   ` fairfield
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Sherwood @ 1995-07-02  4:00 UTC (permalink / raw)


Mike Unverferth (mju@tnt) wrote:
: I have some data files containing values in VAX double-precision.
: I need to convert these values to Intel (IEEE) floating-point.
: Can someone provide the format and/or C code to do the conversion?

The format (D_floating"), is on page 35 of the VAX Architecture Handbook,
and also available in other publications that describe the VAX instruction
set, possibly even in on-line HELP MACRO. The 64-bit data is stored in 4
16-bit words as

sign | 8-bit excess-128 2's exponent | 7-bit ms fraction with 'hidden' bit
16-bit ms-1 fraction
16-bit ms-2 fraction
16-bit ls fraction

-----------------------------------------------------------------------------
Peter Sherwood
(617) 332-8880 (voice)
(617) 969-2101 (fax)
gbcacm@ccs.neu.edu
-----------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: VAX double-precision format
  1995-07-02  4:00 ` Peter Sherwood
@ 1995-07-03  4:00   ` fairfield
  0 siblings, 0 replies; 3+ messages in thread
From: fairfield @ 1995-07-03  4:00 UTC (permalink / raw)


In article <3t76s0$7mc@camelot.ccs.neu.edu>, gbcacm@ccs.neu.edu (Peter Sherwood) writes:
> Mike Unverferth (mju@tnt) wrote:
> : I have some data files containing values in VAX double-precision.
> : I need to convert these values to Intel (IEEE) floating-point.
> : Can someone provide the format and/or C code to do the conversion?
> 
> The format (D_floating"), is on page 35 of the VAX Architecture Handbook,
> and also available in other publications that describe the VAX instruction
> set, possibly even in on-line HELP MACRO. The 64-bit data is stored in 4
> 16-bit words as
> 
> sign | 8-bit excess-128 2's exponent | 7-bit ms fraction with 'hidden' bit
> 16-bit ms-1 fraction
> 16-bit ms-2 fraction
> 16-bit ls fraction

        It should be noted that,  in  addition  to the exponent having a
    bias  of 128, the VAX _normalization_ of the fraction (mantissa)  is
    such that 0.5 <= fraction  <  1.0.   IEEE  is  different.   _Single_
    precision  IEEE  has  a  bias of 127 and the normalixation is 1.0 <=
    frac < 2.0.  The difference in normalization means that once the VAX
    exponent has been extracted  to  a  _signed_  value,  it needs to be
    reduced by 1 before applying the IEEE bias.

        I assume Mike would  want  to  convert  his  VAX doubles to IEEE
    double  precision,  in  which case he needs to know  that  the  IEEE
    Double exponent field is 11 bits wide (cf. 8 bits  for  VAX  F_float
    and  D_float,  and IEEE Single), that the exponent bias is 1023, and
    the normalization of the fraction  is  the  same as for IEEE Single,
    1.0  <=  frac  <  2.0.  In all cases, the  most  significant  binary
    "digit" of the fraction is omitted, but need not  be  considered  in
    the  conversion.   Note  that  there is a 3-bit loss of precision in
    converting from D_float to  IEEE  Double  due  to  the difference in
    exponent and fraction widths.

        The IEEE formats are:

        1        8                  23                     width
      +---+-------------+------------------------+
      | s |     exp     |        fraction        |                Single
      +---+-------------+------------------------+                ______
           msb       lsb msb                  lsb          order

        1         11                    52                 width
      +---+---------------+-----------------------------+
      | s |      exp      |          fraction           |         Double
      +---+---------------+-----------------------------+         ------
           msb         lsb msb                       lsb   order


        On little-endian architectures  (VAX,  Alpha,  Intel), the least
    significant  bit is bit 0, the most significant bit is bit 31 (for a
    32-bit word size), and  thus  the  sign  bit  is  bit  31.   On  VAX
    hardware,  the least significant 32 bits of a 64 bit double _follow_
    at the next address.  That is, if you think of the double as being a
    dimension 2 array of 32  bit  words,  the  2nd array index holds the
    least  significant bits of the fraction.  I would _guess_ that Intel
    architecture does the same, but I have no way to verify that...

        Finally, is those VAX double  precision  data happened to be VAX
    G_float format, then a different conversion will need to be applied.

        -Ken
-- 
 Kenneth H. Fairfield       |  Internet: Fairfield@Slac.Stanford.Edu
 SLAC, P.O.Box 4349, MS 46  |  DECnet:   45537::FAIRFIELD (45537=SLACVX)
 Stanford, CA   94309       |  Voice:    415-926-2924    FAX: 415-926-3515
 -------------------------------------------------------------------------
 These opinions are mine, not SLAC's, Stanford's, nor the DOE's...



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1995-07-03  4:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-06-30  4:00 VAX double-precision format Mike Unverferth
1995-07-02  4:00 ` Peter Sherwood
1995-07-03  4:00   ` fairfield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox