Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: john@yrl.co.uk (John Laird)
Subject: Re: VAX D-Float format
Date: 1997/10/30	[thread overview]
Message-ID: <bXtYylDLlabo@yrl.co.uk> (raw)
In-Reply-To: 34575f82.182344367@serve.installshield.com


In article <34575f82.182344367@serve.installshield.com>, chiehcheng@geocities.com (Chieh Cheng) writes:
> I am trying to decode and decipher Intergraph Microstation's Design
> file format. It uses the VAX D-Float format. Although it is also 64
> bit long, it is somewhat different from the IEEE double float format.
> The format is as follows:
> 
> bit 15: sign
> bit 14 - 7: Exponent
> bit 6 - 0: Exponent
> 
> bit 16 to 63 is the fraction. I assume it is one fraction, however,
> the diagram in the book divided it into three equal parts. Like the
> exponent shown above.
> 
Actually, it is:
Bit  15   : sign
Bits 14-7 : exponent
Bits 6-0  : most significant bits of fraction
Bits 31-16: less significant bits of fraction
Bits 47-32: lesser significant bits of fraction
Bits 63-48: least significant bits of fraction

The least significant fraction bit is bit 48, and the most significant bit is
bit 6.    The layout is apparently illogical in that layed out in ascending
memory order, the fraction bits are not contiguous.  I think it goes back
to PDP-11 days when the two 16-bit words would have been loaded into the FPU
separately.  (If you swap the 16-bit words around, it all looks much better).

You don't say whether you are running on a big-endian or little-endian machine.
It is vital that you know this in order to understand how to translate from
this (VAX) binary D_floating format to your binary IEEE format.

Assuming you are on a big-endian machine, take each 8 bytes and rearrange
them into a byte array in the following order: 2 1 4 3 6 5 8 7.  The bits
will now look like this:

     6
     3                                                              0
     SEEEEEEEEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
     ^^       ^
     ||        - fraction bits, most significant at bit 54
     | --------- exponent bits, most significant at bit 62
      ---------- sign bit

Compare this with your IEEE format, and you should be able to work out how
to shift bits about.  (If you are using a little-endian machine, most likely
Intel, order the bytes 7 8 5 6 3 4 1 2)

There are two other very important points:

a)  The fraction is _normalised_, which is to say it has been represented
as a fraction between 0.5 (inclusive) and 1.0 (exclusive), and the most
significant fraction bit (now always 1) is _not stored_.  In other words,
there is a hidden bit between bits 6 and 7 in the D_float format which is
_always_ 1, and which is to be considered as part of the fraction.  I don't
know off-hand whether IEEE uses normalised fractions with a hidden bit or
not.

b)  The exponent is in excess 128 format, meaning that an actual value of
N is stored as N+128.  Thus the exponent is always apparently positive
in the range 0 to 255, and 128 should be subtracted to give the true value
in the range -128 to 127.  A stored exponent of 0 means one of two things -
if the sign bit is 0, the whole number is zero regardless of the fraction
bits, while if the sign bit is 1, the whole number is a reserved operand or
NaN in some dialects.

-- 
John Laird (john@yrl.co.uk)           "I have discovered a truly elegant sig,
Yezerski Roper Ltd                    sadly there is no room here to show it."
http://www.yrl.co.uk



  reply	other threads:[~1997-10-30  5:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-29  5:00 VAX D-Float format Chieh Cheng
1997-10-30  5:00 ` John Laird [this message]
1997-10-30  5:00 ` Gregg E Economou
1997-10-31  5:00   ` Chieh Cheng
1997-11-05  5:00     ` WTB: Iomega Zip Drive Jerome Fine
     [not found]     ` <199711051454.JAA02820@dbit.dbit.com>
1997-11-05  5:00       ` Jerome Fine
1997-10-30  5:00 ` VAX D-Float format Steve Lionel
1997-10-31  5:00   ` Dik T. Winter
1997-10-31  5:00     ` John Wilson
1997-11-03  5:00       ` Dik T. Winter
1997-11-03  5:00   ` Chieh Cheng
1997-11-05  5:00     ` Steve Lionel
1997-11-06  5:00       ` Philippe Pouliquen
1997-11-10  5:00         ` John Laird
1997-10-30  5:00 ` Steve Atkins
1997-10-31  5:00   ` Pedasmith
1997-10-30  5:00 ` Hoff Hoffman
1997-11-05  5:00 ` John Foust
read-only archive

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