Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Help - DEC floating point format?
@ 1995-03-09 16:27 Andrew Gibbs
  1995-03-10  9:36 ` Dr Ivan D Reid, �SR Facility, PSI
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andrew Gibbs @ 1995-03-09 16:27 UTC (permalink / raw)


Excuse my ignorance but I'm trying to read some datafiles into a PC.
They claim to be floating point and were obtained originally on an 
instrument based on some sort of DEC computer (PDP/Vax??).  All my 
attempts to read this data result in garbage and I would like to know
if the floating point format used is non-IEEE, and if so what is it?
(bit allocations for mantissa/exponent/sign(s) etc)

Thanks for any assistance,

Andrew Gibbs
agi%bsesoft@Britain.EU.net



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

* Re: Help - DEC floating point format?
  1995-03-09 16:27 Help - DEC floating point format? Andrew Gibbs
@ 1995-03-10  9:36 ` Dr Ivan D Reid, �SR Facility, PSI
  1995-03-10 11:56 ` Bob Schor
  1995-03-10 18:05 ` Steve Lionel
  2 siblings, 0 replies; 5+ messages in thread
From: Dr Ivan D Reid, �SR Facility, PSI @ 1995-03-10  9:36 UTC (permalink / raw)


In article <D56Lq2.8Mx@demon.co.uk>,
	 Andrew Gibbs <agi%bsesoft@Britain.EU.net> writes...
>Excuse my ignorance but I'm trying to read some datafiles into a PC.
>They claim to be floating point and were obtained originally on an 
>instrument based on some sort of DEC computer (PDP/Vax??).  All my 
>attempts to read this data result in garbage and I would like to know
>if the floating point format used is non-IEEE, and if so what is it?
>(bit allocations for mantissa/exponent/sign(s) etc)

	Single- or double-precision?  Single-precision should be the same, but
the usual DEC double-precision just adds four bytes of mantissa, keeping the
same exponent (i.e. more precision, but less range than an IEEE double).
As far as I recall, byte order is the same as Intel silicon.

	If you need more help, mail me; I've got DEC and Intel documents here
in the office to get down to the bits 'n' bytes level.

Ivan Reid, Paul Scherrer Institute, CH.     			reid@cvax.psi.ch


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

* Re: Help - DEC floating point format?
  1995-03-09 16:27 Help - DEC floating point format? Andrew Gibbs
  1995-03-10  9:36 ` Dr Ivan D Reid, �SR Facility, PSI
@ 1995-03-10 11:56 ` Bob Schor
  1995-03-10 19:45   ` fairfield
  1995-03-10 18:05 ` Steve Lionel
  2 siblings, 1 reply; 5+ messages in thread
From: Bob Schor @ 1995-03-10 11:56 UTC (permalink / raw)


In article <D56Lq2.8Mx@demon.co.uk> Andrew Gibbs <agi%bsesoft@Britain.EU.net> writes:
>Excuse my ignorance but I'm trying to read some datafiles into a PC.
>They claim to be floating point and were obtained originally on an 
>instrument based on some sort of DEC computer (PDP/Vax??).  All my 
>attempts to read this data result in garbage and I would like to know
>if the floating point format used is non-IEEE, and if so what is it?
>(bit allocations for mantissa/exponent/sign(s) etc)

>Thanks for any assistance,

>Andrew Gibbs
>agi%bsesoft@Britain.EU.net

     The PDP-11 single-precision floating point format is similar to the PC 
single precision format.  There are two differences -- an "endian" problem 
and a "hidden precision" problem.

     Assume you have a four-byte PDP-11 single-precision floating point 
number.  Do the following:

1)  Store the number into a PC floating point variable, but in word-reversed 
order.  That is, the first 16 bits (word) from the PDP go into the second 16 
bits on the PC, and vice versa.  This solves the "endian" problem.

2)  Divide the (PC) floating point number by 4.  This solves the hidden bit 
problem.

     You should now have, in the PC, the representation of the PDP's floating 
point value.  That is, if a Fortran program on the PDP read the PDP value and 
wrote out 3.14159, then the transformed (word-swapped, divided-by-4) value 
written out by a PC Fortran program would also be 3.14159.

     Going the other way is left as a (trivial) exercise for the reader.

Bob Schor
US DECUS RT-11/TSX+ Working Group Chair


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

* Re: Help - DEC floating point format?
  1995-03-09 16:27 Help - DEC floating point format? Andrew Gibbs
  1995-03-10  9:36 ` Dr Ivan D Reid, �SR Facility, PSI
  1995-03-10 11:56 ` Bob Schor
@ 1995-03-10 18:05 ` Steve Lionel
  2 siblings, 0 replies; 5+ messages in thread
From: Steve Lionel @ 1995-03-10 18:05 UTC (permalink / raw)



In article <D56Lq2.8Mx@demon.co.uk>, Andrew Gibbs <agi%bsesoft@Britain.EU.net> writes:
|>Excuse my ignorance but I'm trying to read some datafiles into a PC.
|>They claim to be floating point and were obtained originally on an 
|>instrument based on some sort of DEC computer (PDP/Vax??).  All my 
|>attempts to read this data result in garbage and I would like to know
|>if the floating point format used is non-IEEE, and if so what is it?
|>(bit allocations for mantissa/exponent/sign(s) etc)

I'll assume it's a VAX, though some PDP-11s had similar layouts.

Single-precision:

	Exponent: 8 bits, bias 128, bits 7:14 (little-endian)
	Mantissa: 24 bits, normalized, MSB hidden, 0<m<=0.5
	  MSB 7 bits are in bits 0-6, little-endian; next 16 bits are in 16-31.
	Sign: 1 bit (zero for positive, one for negative): bit 15
	Zero: sign and exponent zero, mantissa ignored

	seeeeeeeemmmmmmm   Bits 0:15
	mmmmmmmmmmmmmmmm   Bits 16:31

Double-precision (D_float):

	Just like single precision but with an extra 32 bits of mantissa
	in bits 32-47 and 48-63

These are the most common formats.

The tricky part is that the mantissa layout is strange - the most significant
bits are in the lowest-addressed bytes.  This layout "looked" normal on
the 16-bit PDP-11, but seems strange on a 32-bit system.  For conversion
to IEEE, don't forget the different position of the radix point and the
different exponent bias.

For single precision, you could probably get by with swapping the 16-bit
words and multiplying by 4. 
-- 

Steve Lionel                      Mail: lionel@quark.enet.dec.com
DEC Fortran Development           WWW:  http://www.digital.com/info/slionel.html
Digital Equipment Corporation     CompuServe: 75263,3001
110 Spit Brook Road, ZKO2-3/N30
Nashua, NH 03062-2698             "Free advice is worth every cent"

For a summary of Digital's Internet services, send mail to info@digital.com


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

* Re: Help - DEC floating point format?
  1995-03-10 11:56 ` Bob Schor
@ 1995-03-10 19:45   ` fairfield
  0 siblings, 0 replies; 5+ messages in thread
From: fairfield @ 1995-03-10 19:45 UTC (permalink / raw)


In article <bschor.44.03CD5D35@vms.cis.pitt.edu>, 
    				bschor@vms.cis.pitt.edu (Bob Schor) writes:
[question about PDP/VAX floating point format deleted]
> 
>      The PDP-11 single-precision floating point format is similar to the PC 
> single precision format.  There are two differences -- an "endian" problem 
> and a "hidden precision" problem.

        I think it's confusing to say  this is an "endian" problem since
    both  Intel,  and  PDP & VAX, use "little-endian"  addressing.   You
    could say it's _similar_ to an endian problem, but it  applies  only
    to the floating point format and only at word (16-bit) granularity.

        The reason for this seemingly odd  format is that it allowed the
    word  that  contains the sign bit (MSB word) of the 4-byte float  to
    sit in R0 and set the hardware status register flags on the PDP (and
    VAX).  If the float was constructed in the "natural"  4-byte  order,
    the   sign  bit  would  appear  in  R1,  would  not  set  the  flags
    appropriately (for a float) and the  test for negative or zero would
    have  had to be done in software (slowing things down a lot!).  It's
    a bit of a hack, but it makes sense for the hardware on which it was
    developed (and the VAX hardware maintained  compatibility  with  the
    PDP format).

        Secondly, it's not  a  "hidden  precision"  problem (I think you
    meant   hidden  _bit_,  BTW),  but  rather  a  different  choice  of
    _normalization_.  Both IEEE and PDP/VAX floating point formats use a
    "hidden bit" in the mantissa, but IEEE chose to normalize as  1.bbbb
    whereas PDP and VAX use 0.1bbbb (and only the "bbbb" are represented
    in the mantissa bits).  In addition, IEEE chose to use a bias of 127
    (versus  128  on PDP/VAX) for the 8 bits of exponent which gave them
    (1) symmetric value range and  (2)  some extra exponent values which
    can  be used for NaN, Inf, etc.  So you get one factor of 2 from the
    binary normalization and a second factor  of  2  from  the  exponent
    bias,  resulting  in  a  factor-of-4  difference  between  IEEE  and
    (re-ordered) PDP/VAX float.  Single precision only, BTW.

>      Assume you have a four-byte PDP-11 single-precision floating point 
> number.  Do the following:
> 
> 1)  Store the number into a PC floating point variable, but in word-reversed 
> order.  That is, the first 16 bits (word) from the PDP go into the second 16 
> bits on the PC, and vice versa.  This solves the "endian" problem.
> 
> 2)  Divide the (PC) floating point number by 4.  This solves the hidden bit 
> problem.

        Nice prescription.

            -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] 5+ messages in thread

end of thread, other threads:[~1995-03-10 19:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-03-09 16:27 Help - DEC floating point format? Andrew Gibbs
1995-03-10  9:36 ` Dr Ivan D Reid, �SR Facility, PSI
1995-03-10 11:56 ` Bob Schor
1995-03-10 19:45   ` fairfield
1995-03-10 18:05 ` Steve Lionel

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