[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference vaxaxp::vmsnotes

Title:VAX and Alpha VMS
Notice:This is a new VMSnotes, please read note 2.1
Moderator:VAXAXP::BERNARDO
Created:Wed Jan 22 1997
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:703
Total number of notes:3722

504.0. "Float exponent query" by KERNEL::BIRKINSHAW (Press Enter to Exit) Mon Apr 21 1997 12:46

VMS 7.1 Fortran 7.0

I'm trying to understand how the f-float exponent
bits are handled. 

Here is an  example for the floating point value of 
4.0 

00000000 00000000 01000001 10000000

The exponent is in bits 14:7 which gives an exponent 
value of 131 (dec). The mantissa is all zeroes which
in this case equate to a value of 1 (using the hidden bit)

Working this through...

	float value = 2**(exponent - excess) * mantissa
	float value = 2**(131      - 128   ) * 1 = 8

So I find the excess bias to be 129 not 128.

Can someone explain this to me?
Thanks
Simon
T.RTitleUserPersonal
Name
DateLines
504.1move the decimal point one way or anotherWIBBIN::NOYCEPulling weeds, pickin' stonesMon Apr 21 1997 13:068
Well, you could look at it that way.  Alternatively, the way VAX architects
look at it, the fraction has a value of 1/2 (the radix point is just to the
left of the hidden bit).

For IEEE single, the radix point is considered to be just to the right of the
hidden bit, as you're assuming, and the exponent offset is 127 -- these
combine to mean that similar bit patterns (after swapping words) give values
that differ by a factor of 4.0.
504.2details of number representationKZIN::HUDSONThat's what I thinkWed Apr 23 1997 09:3273
Hi Simon

When working at the CSC I had cause to answer customer questions on this
problem and wrote a program, the output of which may help... (if you want a
copy of the program, let me know)

nick

$ r float
This program will convert from the hex representation of a VAX floating
number into the precise floating point decimal equivalent, and can show
workings as it goes.


Would you like F_FLOAT, D_FLOAT or G_FLOAT (F/D/G) ? F


Please enter the hex representation of number.  Each hex
Number you enter should include any leading zeros

Please give first longword in hex  : 00004180


Do you want to see intermediate workings ? Y

The hex value 
00004180 represents the following decimal value...

A F_FLOAT looks like this :

	32             16|15       7|6     0
	+----------------+-+--------+-------+
	|    fraction2   |S|exponent|fract1 |
	+----------------+-+--------+-------+
	32             16|15       7|6     0

The number looks like this :

	32             16|15       7|6     0
	+----------------+-+--------+-------+
	|0000000000000000|+|10000011|0000000|
	+----------------+-+--------+-------+
	32             16|15       7|6     0


The most significant bit of the fraction is ALWAYS considered to be set, and
so does not need to be stored.  Given that, the full fractional part is :
	    <frac1>     <frac2>
	+0.10000000 0000000000000000 

Which represents the sum of the following (decimal) numbers : 
	+0.5
================================================================================
Total=	+0.5
================================================================================

The exponent is 131 which is held in excess 128 format, giving a true
exponent of 3


So to find the actual number, we now have to multiply the fraction by 2^3


Which works out to 
	 0.5
	*8.


The precise number represented is : 
================================================================================
	+4.
================================================================================

504.3QUARK::LIONELFree advice is worth every centWed Apr 23 1997 10:3235
The OpenVMS FAQ discusses this:

VAX2.   What is the layout of the VAX floating point format?

The VAX floating point format is derived from one of the PDP-11 FP formats,
which helps explain its strange layout.  There are four formats defined:
F 32-bit single-precision, D and G 64-bit double-precision and H 128-bit
quadruple precision.  For all formats, the lowest addressed 16-bit "word"
contains the sign and exponent (and for other than H, some of the most
significant fraction bits).  Each successive higher-addressed word contains
the next 16 lesser-significant fraction bits.  Bit 15 of the first word is the
sign, 1 for negative, 0 for positive.  Zero is represented by a biased
exponent value of zero and a sign of zero; the fraction bits are ignored (but
on Alpha, non-zero fraction bits in a zero value cause an error.)  A value
with biased exponent zero and sign bit 1 is a "reserved operand" - touching
it causes an error - fraction bits are ignored.  There are no minus zero,
infinity, denormalized or NaN values.

For all formats, the fraction is normalized and the radix point assumed to be
to the left of the MSB, hence 0.5 <= f < 1.0.  The MSB, always being 1, is
not stored.  The binary exponent is stored with a bias varying with type in
bits 14:n of the lowest-addressed word.

  Type    Exponent bits    Exponent bias    Fraction bits (including hidden)
  ==========================================================================
   F           8                128               24
   D           8                128               56
   G          11               1024               53
   H          15              16384              113

The layout for D is identical to that for F except for 32 additional
fraction bits.

Example:  +1.5 in F float is hex 000040C0 (fraction of .11[base 2], biased
exponent of 129)
504.4MOVIES::WIDDOWSONRod OpenVMS Engineering. Project RockWed Apr 23 1997 10:4918
    ... and for the sake of history
    
    IMHO, One of the most glorious hacks in the VAX/VMS masterpack was
    perpetrated by Andy Goldstein almost 20 years ago.  The basic problem
    is of finding the lefthand most set bit in a longword (by analogy to
    the FFS instruction this would be FLS).
    
    Andy claims that this was inspired by Hustvedt:
    
    LEFT_ONE::
    	.WORD   ^M<>             ; NO REGISTERS SAVED
    	MOVL    #32,R0           ; ASSUME NEGATIVE
    	BBS     #31,ARG(AP),10$  ; BRANCH TO END IF NEGATIVE
    	CVTLD   ARG(AP),R0	 ; CONVERT TO DOUBLE FLOATING
    	EXTZV   #7,#7,R0,R0	 ; GET EXPONENT, LESS EXCESS 128
    10$:    RET		        	; AND THAT'S ALL
    
    
504.5er, maybe I just saw some light ...BBPBV1::WALLACEjohn wallace @ bbp. +44 860 675093Wed Apr 23 1997 19:189
    Would a hack like this be in the code path of $MOUNT, by any chance ?
    
    I once had a customer with a 785 which was on third party maintenance.
    It wouldn't mount disks. Third party had no diags, Digital diags said
    "FPU broke", me not understanding why FPU would get involved in $MOUNT,
    but engineer swapped anyway and problem disappears...
    
    regards
    john
504.6780/785 FPU also accelerated integer mutiply....STAR::CROLLThu Apr 24 1997 11:379
The FPU on the 780 and 785 also accelerated some integer
operations.  There have been a number of instances where
fixing the FPU fixed some other, obviously non-floating
point, problem.

I know the FPU accelerated integer mutiply, but can't
remember what else it helped with...

John
504.7Fixing FPU Cleared Locking ProblemsXDELTA::HOFFMANSteve, OpenVMS EngineeringThu Apr 24 1997 12:094
   And faulty VAX-11/78x-class FPU boards were notorious for inducing
   odd problems deep in the lock manager...

504.8QUARK::LIONELFree advice is worth every centThu Apr 24 1997 13:383
... and LMF!

		Steve
504.9UTRTSC::utojvdbu1.uto.dec.com::JurVanDerBurgChange mode to Panic!Fri Apr 25 1997 03:274
Don't forget LOGIN problems.

Jur.

504.10MOVIES::WIDDOWSONRod OpenVMS Engineering. Project RockFri Apr 25 1997 05:058
    RE: <<< Note 504.5 by BBPBV1::WALLACE "john wallace @ bbp. +44 860 675093" >>>
    
>>    Would a hack like this be in the code path of $MOUNT, by any chance ?
    
    Got it in one John!
    
    One of my first jobs in digital was to `port' this to Alpha.  Strange
    that it should come to light as I work out my notice....