From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,ab02531b71c8f5fd X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1995-03-10 19:20:50 PST Newsgroups: comp.sys.dec Path: bga.com!news.sprintlink.net!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!fnnews.fnal.gov!unixhub!sldb6.slac.stanford.edu!fairfield From: fairfield@sldb6.slac.stanford.edu Subject: Re: Help - DEC floating point format? Message-ID: <1995Mar10.114549.1@sldb6.slac.stanford.edu> Sender: news@unixhub.SLAC.Stanford.EDU Organization: Stanford Linear Accelerator Center References: Date: Fri, 10 Mar 1995 19:45:49 GMT In article , 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...