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

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

232.0. "x(integer) = y(floating)" by SPRITE::OSMAN () Fri Mar 08 1985 10:43

In HAKMEM, published at MIT Artificial Intelligence Lab, there was shown
some obscure 36-bit number (other than the trivial case of 0) that
had the property that it represented the same integer and floating point
number within the architecture of the PDP6/PDP10 series.

Is there a 32-bit VAX architecture value other than 0 that has this same
property ?
T.RTitleUserPersonal
Name
DateLines
232.1METOO::YARBROUGHMon Mar 11 1985 12:1018
Here's a litle FORTRAN program to investigate the problem. The shortest 
cycle of values I have been able to get from this is
	2093010816. -> -2120265728. -> -1050619904. -> 2093010816.
which is obtained from most starting values of 'i'.
I have observed two longer cycles from i=-103 and i=-10003. There may yet
be values of i which produce a single-value cycle.


	INTEGER*4	i
	REAL*4		f
	EQUIVALENCE	(i,f)
C
	i = 1
100	f = FLOAT(i)
	TYPE 200, f
200	FORMAT (F20.2)
	goto 100
	END
232.2SPRITE::OSMANTue Mar 12 1985 10:054
Perhaps some vax architecture wizard could enlighten us with the floating
storage format.  That we we could attack the problem mathematically.

(I assume most of us already know the integer storage format :-)
232.3HARE::STANTue Mar 12 1985 13:461
VAX data representations are in the architecture handbook.
232.4NACHO::MCMENEMYThu Mar 14 1985 07:5051
re:0	Their is no such number.

	I tried to figure out an easy way to determine this or at least cut
	down the number of possible cases to check.

	The best I could do was to scan the numbers from

	16512 - 2147450879. 

re:2	Basically F_floating format is stored in three parts:

		o	sign of fraction
		o	exponent stored in 128 excess notation
		o	fraction is a normalized fraction with 1 hidden bit:

		A floating point number is defined has having the form
			(2 ^K)*f, where K is an integer and f is a fraction.

	Here are a few examples of this: (don't forget the hidden bit, which
		gives you an additional bit for the fraction)


	The number 1.0 would be the following:

	16512		- base 10
	0000 4080	- base 16
			      |	           |
	0000 0000 0000 0000 0 | 100 0000  1|000 0000
			      |		   |

					2^1 x (hidden bit) or
					2^1 x (1/ (2^1) )
					2 x .5 = 1.0

	Another example for the number 3 would be:

	16704		- base 10
	0000 4140	- base 16
			      |	           |
	0000 0000 0000 0000 0 | 100 0001  0|100 0000
			      |		   |

					2^2 x (hidden bit) + (1/ (2^2) ) or
					2^2 x (1/ (2^1) )  + (1/ (2^2) )
					4 x (.5 + .25)
					4 x (.75) = 3.0


			

				Mike Mc Menemy
232.5LATOUR::JMUNZERThu Mar 14 1985 16:58146
INTRODUCTION:

A 32-bit floating point number is

	llll llll llll llll seee eeee ehhh hhhh

where	(l31, l30, ..., l16)	are low order fraction bits
	(s15)			is the sign bit
	(e14, e13, ..., e7) 	are exponent bits
	(h6, h5, ..., h0) 	are high order fraction bits

and its value is

	(.1hhh hhhh llll llll llll llll) *

		(2 ^ (eeee eeee - 1000 0000)) * ((-1) ^ s)  {pardon the 2}

 **  **  **  **  **  **  **  ** 

E.g.
      	llll llll llll llll seee eeee ehhh hhhh

	1010 1010 1000 0000 0100 1000 0010 1010
is 
	(.1010 1010 1010 1010 1000 0000) * 

		(2 ^ (1001 0000 - 1000 0000)) * ((-1) ^ 0)

	= (.1010 1010 1010 1010 1) * (1 0000 0000 0000 0000) * (1)

	= 1010 1010 1010 1010.1

	= 43,690.5 in decimal

 **  **  **  **  **  **  **  ** 

NOTATION:	let X be a 32-bit configuration, and

	F(X) be its value when interpreted as floating point, and
	I(X) be its value when interpreted as a nonzero integer, and

	E be the value of eeee eeee,
	H be the value of hhh hhhh,
	L be the value of llll llll llll llll


As above, F(X) =

	(2 ^ (-1) + H * (2 ^ (-8)) + L * (2 ^ (-24))
		* (2 ^ (E - 128)) * ((-1) ^ s) 

	= 2 ^ (E - 129)    +    H * 2 ^ (E - 136)    +    L * 2 ^ (E - 152),
	
or its negative.

 **  **  **  **  **  **  **  ** 

#### ---- ####            If F(X) = I(X), then:         #### ---- ####

PARTIAL RESULT #1:	129 <= E <= 159 
                            
	I(X) is not zero, and I(X) is not -2^31 (E would be zero), so

		2^0 <= ABS (I(X)) < 2^31
	So 	                                       
		2^0 <= 2^(E-129) < 2^31 
	So
		0 <= E-129 < 31
	So
		129 <= E <= 159

PARTIAL RESULT #2:	x31 (bit 31 of X) is one.  So I(X) = F(X) < 0. 

	If not, then I(X) is positive.  Then I(X) is

		1hhh hhhh llll llll llll llll, with leading and/or trailing

	zeros, and has a total of

		1 + (# 1 bits in H) + (# 1 bits in L)

	bits.  But F(X) will have  
		
		(# 1 bits in E) + (# 1 bits in H) + (# 1 bits in L)

	bits, which is more for any E that satisfies Partial Result #1.

SUMMARY:       	X is

	1lll llll llll llll 1100 eeee ehhh hhhh, where eeeee nonzero.

		ABS(I) is (-I(X)) =

	0mmm mmmm mmmm mmmm 0011 ???? ???? ????,

		where m's are complements of l's

ASIDE:  if J is an integer, and bit b is one, then J =

		jjjj jjjj jjjj jjjj jjjj jj1? ???? ????
					    <--- b ---> 
	and COMPLEMENT(J) =

		kkkk kkkk kkkk kkkk kkkk kk0? ???? ????

	and (-J) =
		kkkk kkkk kkkk kkkk kkkk kk?? ???? ????

	where k's are complements of j's.
	
PARTIAL RESULT #3:	143 <= E <= 159

	2^(E - 129) >= ABS(I) >= 0011 0000 0000 0000 > 2^13 	

PARTIAL RESULT #4:	E is not 159

	Suppose E = 159.  Then

		[a] F(X) = 	1lll llll llll llll 1100 1111 1hhh hhhh

	Then	[b] I(X) =	1lll llll llll llll 1100 1111 1hhh hhhh

      	Then	[c] ABS(I(X)) = 0mmm mmmm mmmm mmmm 0011 0000 ???? ????

	The integer part of F(X) [= ABS(I(X))] =

		[d] ABS(I(X)) =	01hh hhhh h1ll llll llll llll l000 0000

	From [c] and [d]:  l24,l23,l22,l21  l20,l19,l18,l17 = 0011 0000

	From [b] and [c]:  m24,m23,m22,m21  m20,m19,m18,m17 = 1100 1111

	From [c] and [d]:  h1,h0,1,l30  l29,l28,l27,l26     = 1100 1111

	Nope.  Contradiction:    1..............................0


 **  **  **  **  **  **  **  ** 

PROBLEM:  Partial Result #4 has very little bang for the buck, and needs
to be followed by Partial Results #5 (E is not 158), #6 (E is not 157),
..., #20 (E is not 143).  They're doable, but error prone.  And awfully
long.  I've tried, and it appears to me that no E has a solution.

But a satisfactory proof that there are no solutions would seem to require
something neater than the likes of Partial Result #4.