many changes, to use IEEE format
This commit is contained in:
		
							parent
							
								
									c7be2d1a44
								
							
						
					
					
						commit
						f7360f0fec
					
				
					 32 changed files with 223 additions and 254 deletions
				
			
		|  | @ -9,7 +9,6 @@ | ||||||
| 	include file for floating point package | 	include file for floating point package | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| #ifdef	IEEEFORMAT |  | ||||||
| 		/*	FLOAT FORMAT EXPONENT BIAS	*/ | 		/*	FLOAT FORMAT EXPONENT BIAS	*/ | ||||||
| 
 | 
 | ||||||
| #define	SGL_BIAS	 127	/* excess  128 notation used	*/ | #define	SGL_BIAS	 127	/* excess  128 notation used	*/ | ||||||
|  | @ -21,29 +20,9 @@ | ||||||
| 		/*	VARIOUS MAX AND MIN VALUES	*/ | 		/*	VARIOUS MAX AND MIN VALUES	*/ | ||||||
| 		/*	1) FOR THE DIFFERENT FORMATS	*/ | 		/*	1) FOR THE DIFFERENT FORMATS	*/ | ||||||
| 
 | 
 | ||||||
| #define	SGL_MAX		   255	/*	standard definition	*/ | #define	SGL_MAX		   254	/*	standard definition	*/ | ||||||
| #define	SGL_MIN		     1	/*	standard definition	*/ | #define	SGL_MIN		     1	/*	standard definition	*/ | ||||||
| #define	DBL_MAX		  2047	/*	standard definition	*/ | #define	DBL_MAX		  2046	/*	standard definition	*/ | ||||||
| #define	DBL_MIN		     1	/*	standard definition	*/ | #define	DBL_MIN		     1	/*	standard definition	*/ | ||||||
| #define EXT_MAX		 16384	/*	standard minimum	*/ | #define EXT_MAX		 16383	/*	standard minimum	*/ | ||||||
| #define EXT_MIN		-16383	/*	standard minimum	*/ | #define EXT_MIN		-16382	/*	standard minimum	*/ | ||||||
| #else |  | ||||||
| 
 |  | ||||||
| 		/*	FLOAT FORMAT EXPONENT BIAS	*/ |  | ||||||
| 
 |  | ||||||
| #define	SGL_BIAS	 127	/* excess  128 notation used	*/ |  | ||||||
| #define	DBL_BIAS	127	/* excess 128 notation used	*/ |  | ||||||
| #define	EXT_BIAS	   0	/* 2s-complement notation used	*/ |  | ||||||
| 				/* this is possible because the	*/ |  | ||||||
| 				/* sign is in a seperate word	*/ |  | ||||||
| 		 |  | ||||||
| 		/*	VARIOUS MAX AND MIN VALUES	*/ |  | ||||||
| 		/*	1) FOR THE DIFFERENT FORMATS	*/ |  | ||||||
| 
 |  | ||||||
| #define	SGL_MAX		   255	/*	standard definition	*/ |  | ||||||
| #define	SGL_MIN		     1	/*	standard definition	*/ |  | ||||||
| #define	DBL_MAX		  255	/*	standard definition	*/ |  | ||||||
| #define	DBL_MIN		     1	/*	standard definition	*/ |  | ||||||
| #define EXT_MAX		 16384	/*	standard minimum	*/ |  | ||||||
| #define EXT_MIN		-16383	/*	standard minimum	*/ |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|  | @ -26,32 +26,13 @@ | ||||||
| #define	SGL_MASK	0x007fffffL | #define	SGL_MASK	0x007fffffL | ||||||
| 
 | 
 | ||||||
| 				/* parameters for Double Precision */ | 				/* parameters for Double Precision */ | ||||||
| #ifndef	IEEEFORMAT |  | ||||||
| 
 |  | ||||||
| #define DBL_EXPSHIFT	SGL_EXPSHIFT |  | ||||||
| #define DBL_M1LEFT	SGL_M1LEFT |  | ||||||
| 
 |  | ||||||
| #define	DBL_LPACK	DBL_RUNPACK |  | ||||||
| #define	DBL_RPACK	DBL_LUNPACK |  | ||||||
| 
 |  | ||||||
| #define DBL_ZERO	SGL_ZERO |  | ||||||
| #define DBL_EXACT	SGL_EXACT |  | ||||||
| 
 |  | ||||||
| #define DBL_RUNPACK	DBL_M1LEFT |  | ||||||
| #define DBL_LUNPACK	32-DBL_M1LEFT |  | ||||||
| 
 |  | ||||||
| #define DBL_ROUNDUP	SGL_ROUNDUP |  | ||||||
| #define	DBL_CARRYOUT	SGL_CARRYOUT |  | ||||||
| #define	DBL_MASK	SGL_MASK |  | ||||||
| 
 |  | ||||||
| #else |  | ||||||
| 				/* used in extend.c */ | 				/* used in extend.c */ | ||||||
| 
 | 
 | ||||||
| #define DBL_EXPSHIFT	4 | #define DBL_EXPSHIFT	4 | ||||||
| 
 | 
 | ||||||
| #define DBL_M1LEFT	11 | #define DBL_M1LEFT	11 | ||||||
| 
 | 
 | ||||||
| #define	DBL_RPACK	32-DBL_M1LEFT | #define	DBL_RPACK	(32-DBL_M1LEFT) | ||||||
| #define	DBL_LPACK	DBL_M1LEFT | #define	DBL_LPACK	DBL_M1LEFT | ||||||
| 
 | 
 | ||||||
| 				/* used in compact.c */ | 				/* used in compact.c */ | ||||||
|  | @ -61,10 +42,8 @@ | ||||||
| #define DBL_EXACT	0x7ff | #define DBL_EXACT	0x7ff | ||||||
| 
 | 
 | ||||||
| #define DBL_RUNPACK	DBL_M1LEFT | #define DBL_RUNPACK	DBL_M1LEFT | ||||||
| #define DBL_LUNPACK	32-DBL_RUNPACK | #define DBL_LUNPACK	(32-DBL_RUNPACK) | ||||||
| 
 | 
 | ||||||
| #define DBL_ROUNDUP	0x400 | #define DBL_ROUNDUP	0x400 | ||||||
| #define	DBL_CARRYOUT	0x00200000L | #define	DBL_CARRYOUT	0x00200000L | ||||||
| #define	DBL_MASK	0x000fffffL | #define	DBL_MASK	0x000fffffL | ||||||
| 
 |  | ||||||
| #endif	IEEEFORMAT |  | ||||||
|  |  | ||||||
|  | @ -8,47 +8,43 @@ CFLAGS= | ||||||
| #
 | #
 | ||||||
| #	$Header$
 | #	$Header$
 | ||||||
| #
 | #
 | ||||||
| # various flags that can be used during compilation
 | EMFLAGS= -L -LIB -I. -O $(CFLAGS) | ||||||
| # define DEBUG
 |  | ||||||
| # define PRT_ADD
 |  | ||||||
| # define PRT_ALL
 |  | ||||||
| # define PRT_DBL
 |  | ||||||
| # define PRT_ENTRY
 |  | ||||||
| # define PRT_EXIT
 |  | ||||||
| # define PRT_EXT
 |  | ||||||
| # define PRT_EXT2
 |  | ||||||
| # define PRT_LONG
 |  | ||||||
| # define PRT_RNDMSG
 |  | ||||||
| # define PRT_STDERR
 |  | ||||||
| # define PRT_TRAP
 |  | ||||||
| #
 |  | ||||||
| # DFLAGS=-DPRT_ADD -DPRT_ALL -DPRT_DBL -DPRT_ENTRY -DPRT_EXIT -DPRT_EXT -DPRT_EXT2 -DPRT_LONG -DPRT_RNDMSG -DPRT_STDERR -DPRT_TRAP
 |  | ||||||
| DFLAGS= |  | ||||||
| EMFLAGS= -L -LIB -I. $(DFLAGS) -O $(CFLAGS) |  | ||||||
| #	AS=ack -m$(MACH) -c.$(SUF)
 | #	AS=ack -m$(MACH) -c.$(SUF)
 | ||||||
| #	CC=ack -m$(MACH) -c.s
 | #	CC=ack -m$(MACH) -c.s
 | ||||||
| #	CCFLAGS=$(EMFLAGS)
 | #	CCFLAGS=$(EMFLAGS)
 | ||||||
| CDIR=$(EMHOME)/mach/proto/fp | CDIR=$(EMHOME)/mach/proto/fp | ||||||
| 
 | 
 | ||||||
| LIST =		cff4.$(SUF) cff8.$(SUF) cfu.$(SUF) cmf4.$(SUF) cmf8.$(SUF)\
 | LIST =		cff4.$(SUF) cff8.$(SUF)\
 | ||||||
|  | 		cfu.$(SUF)\
 | ||||||
|  | 		cmf4.$(SUF) cmf8.$(SUF)\
 | ||||||
| 		cuf4.$(SUF) cuf8.$(SUF)\
 | 		cuf4.$(SUF) cuf8.$(SUF)\
 | ||||||
| 		dvf4.$(SUF) dvf8.$(SUF) fef4.$(SUF) fef8.$(SUF)\
 | 		dvf4.$(SUF) dvf8.$(SUF)\
 | ||||||
|  | 		fef4.$(SUF) fef8.$(SUF)\
 | ||||||
| 		fif4.$(SUF) fif8.$(SUF)\
 | 		fif4.$(SUF) fif8.$(SUF)\
 | ||||||
| 		cfi.$(SUF) cif4.$(SUF) cif8.$(SUF) mlf4.$(SUF) mlf8.$(SUF)\
 | 		cfi.$(SUF)\
 | ||||||
| 		ngf4.$(SUF)\
 | 		cif4.$(SUF) cif8.$(SUF)\
 | ||||||
| 		ngf8.$(SUF) sbf4.$(SUF) sbf8.$(SUF) adf4.$(SUF) adf8.$(SUF)\
 | 		mlf4.$(SUF) mlf8.$(SUF)\
 | ||||||
|  | 		ngf4.$(SUF) ngf8.$(SUF)\
 | ||||||
|  | 		sbf4.$(SUF) sbf8.$(SUF)\
 | ||||||
|  | 		adf4.$(SUF) adf8.$(SUF)\
 | ||||||
| 		zrf4.$(SUF) zrf8.$(SUF)\
 | 		zrf4.$(SUF) zrf8.$(SUF)\
 | ||||||
| 		extend.$(SUF) compact.$(SUF)\
 | 		extend.$(SUF) compact.$(SUF)\
 | ||||||
| 		add_ext.$(SUF) div_ext.$(SUF) mul_ext.$(SUF) nrm_ext.$(SUF)\
 | 		add_ext.$(SUF) div_ext.$(SUF) mul_ext.$(SUF) nrm_ext.$(SUF)\
 | ||||||
| 		sft_ext.$(SUF) sub_ext.$(SUF) zrf_ext.$(SUF)\
 | 		sft_ext.$(SUF) sub_ext.$(SUF) zrf_ext.$(SUF)\
 | ||||||
| 		adder.$(SUF) shifter.$(SUF) fptrp.$(SUF) | 		adder.$(SUF) shifter.$(SUF) fptrp.$(SUF) | ||||||
| SLIST =		cff4.s cff8.s cfu.s cmf4.s cmf8.s\
 | SLIST =		cff4.s cff8.s\
 | ||||||
|  | 		cfu.s\
 | ||||||
|  | 		cmf4.s cmf8.s\
 | ||||||
| 		cuf4.s cuf8.s\
 | 		cuf4.s cuf8.s\
 | ||||||
| 		dvf4.s dvf8.s fef4.s fef8.s\
 | 		dvf4.s dvf8.s\
 | ||||||
|  | 		fef4.s fef8.s\
 | ||||||
| 		fif4.s fif8.s\
 | 		fif4.s fif8.s\
 | ||||||
| 		cfi.s cif4.s cif8.s mlf4.s mlf8.s\
 | 		cfi.s\
 | ||||||
| 		ngf4.s\
 | 		cif4.s cif8.s\
 | ||||||
| 		ngf8.s sbf4.s sbf8.s adf4.s adf8.s\
 | 		mlf4.s mlf8.s\
 | ||||||
|  | 		ngf4.s ngf8.s\
 | ||||||
|  | 		sbf4.s sbf8.s\
 | ||||||
|  | 		adf4.s adf8.s\
 | ||||||
| 		zrf4.s zrf8.s\
 | 		zrf4.s zrf8.s\
 | ||||||
| 		extend.s compact.s\
 | 		extend.s compact.s\
 | ||||||
| 		add_ext.s div_ext.s mul_ext.s nrm_ext.s\
 | 		add_ext.s div_ext.s mul_ext.s nrm_ext.s\
 | ||||||
|  | @ -56,13 +52,19 @@ SLIST =		cff4.s cff8.s cfu.s cmf4.s cmf8.s\ | ||||||
| 		adder.s shifter.s fptrp.s | 		adder.s shifter.s fptrp.s | ||||||
| 
 | 
 | ||||||
| SRC =		FP_bias.h FP_shift.h FP_trap.h FP_types.h adder.h get_put.h\
 | SRC =		FP_bias.h FP_shift.h FP_trap.h FP_types.h adder.h get_put.h\
 | ||||||
| 		cff4.c cff8.c cfu.c cmf4.c cmf8.c\
 | 		cff4.c cff8.c\
 | ||||||
|  | 		cfu.c\
 | ||||||
|  | 		cmf4.c cmf8.c\
 | ||||||
| 		cuf4.c cuf8.c\
 | 		cuf4.c cuf8.c\
 | ||||||
| 		dvf4.c dvf8.c fef4.c fef8.c\
 | 		dvf4.c dvf8.c\
 | ||||||
|  | 		fef4.c fef8.c\
 | ||||||
| 		fif4.c fif8.c\
 | 		fif4.c fif8.c\
 | ||||||
| 		cfi.c cif4.c cif8.c mlf4.c mlf8.c\
 | 		cfi.c\
 | ||||||
| 		ngf4.c\
 | 		cif4.c cif8.c\
 | ||||||
| 		ngf8.c sbf4.c sbf8.c adf4.c adf8.c\
 | 		mlf4.c mlf8.c\
 | ||||||
|  | 		ngf4.c ngf8.c\
 | ||||||
|  | 		sbf4.c sbf8.c\
 | ||||||
|  | 		adf4.c adf8.c\
 | ||||||
| 		zrf4.c zrf8.c\
 | 		zrf4.c zrf8.c\
 | ||||||
| 		extend.c compact.c\
 | 		extend.c compact.c\
 | ||||||
| 		add_ext.c div_ext.c mul_ext.c nrm_ext.c\
 | 		add_ext.c div_ext.c mul_ext.c nrm_ext.c\
 | ||||||
|  |  | ||||||
|  | @ -27,12 +27,15 @@ register EXTEND	*e1,*e2; | ||||||
| 		if (e2->m1 > e1->m1 || | 		if (e2->m1 > e1->m1 || | ||||||
|                     (e2->m1 == e1->m1 && e2->m2 > e1->m2)) { |                     (e2->m1 == e1->m1 && e2->m2 > e1->m2)) { | ||||||
|                 	/*      abs(e2) > abs(e1) */ |                 	/*      abs(e2) > abs(e1) */ | ||||||
|                 	if (e1->m2 > e2->m2) { | 			EXTEND x; | ||||||
|                         	e2->m1 -= 1;    /* carry in */ | 
 | ||||||
|  | 			x = *e1; | ||||||
|  | 			*e1 = *e2; | ||||||
|  |                 	if (x.m2 > e1->m2) { | ||||||
|  |                         	e1->m1 -= 1;    /* carry in */ | ||||||
|                 	} |                 	} | ||||||
|                 	e2->m1 -= e1->m1; |                 	e1->m1 -= x.m1; | ||||||
|                 	e2->m2 -= e1->m2; |                 	e1->m2 -= x.m2; | ||||||
|                 	*e1 = *e2; |  | ||||||
|         	} |         	} | ||||||
|         	else { |         	else { | ||||||
|                 	if (e2->m2 > e1->m2) |                 	if (e2->m2 > e1->m2) | ||||||
|  |  | ||||||
|  | @ -29,5 +29,5 @@ _float	s1,s2; | ||||||
| 	extend((_double *)&s2,&e2,sizeof(SINGLE)); | 	extend((_double *)&s2,&e2,sizeof(SINGLE)); | ||||||
| 	add_ext(&e1,&e2); | 	add_ext(&e1,&e2); | ||||||
| 	compact(&e1,(_double *)&s1,sizeof(SINGLE)); | 	compact(&e1,(_double *)&s1,sizeof(SINGLE)); | ||||||
| 	return(s1); | 	return s1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -29,5 +29,5 @@ _double	s1,s2; | ||||||
| 	extend(&s2,&e2,sizeof(_double)); | 	extend(&s2,&e2,sizeof(_double)); | ||||||
| 	add_ext(&e1,&e2); | 	add_ext(&e1,&e2); | ||||||
| 	compact(&e1,&s1,sizeof(_double)); | 	compact(&e1,&s1,sizeof(_double)); | ||||||
| 	return(s1); | 	return s1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -17,6 +17,7 @@ | ||||||
| 
 | 
 | ||||||
| #include	"FP_types.h" | #include	"FP_types.h" | ||||||
| 
 | 
 | ||||||
|  | _float | ||||||
| cff4(src) | cff4(src) | ||||||
| _double	src;	/* the source itself -	THIS TIME it's DOUBLE */ | _double	src;	/* the source itself -	THIS TIME it's DOUBLE */ | ||||||
| { | { | ||||||
|  | @ -24,4 +25,5 @@ _double	src;	/* the source itself -	THIS TIME it's DOUBLE */ | ||||||
| 
 | 
 | ||||||
| 	extend(&src,&buf,8);	/* no matter what */ | 	extend(&src,&buf,8);	/* no matter what */ | ||||||
| 	compact(&buf,(_double *) &(src.__double[1]),4); | 	compact(&buf,(_double *) &(src.__double[1]),4); | ||||||
|  | 	return *(_float *)&(src.__double[1]); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -17,11 +17,13 @@ | ||||||
| 
 | 
 | ||||||
| #include "FP_types.h" | #include "FP_types.h" | ||||||
| 
 | 
 | ||||||
|  | _double | ||||||
| cff8(src) | cff8(src) | ||||||
| _float	src;	/* the space on the stack is for a double - see cg/table */ | _float	src; | ||||||
| { | { | ||||||
| 	EXTEND	buf; | 	EXTEND	buf; | ||||||
| 
 | 
 | ||||||
| 	extend((_double *) &src,&buf,4);	/* no matter what */ | 	extend((_double *) &src,&buf,4);	/* no matter what */ | ||||||
| 	compact(&buf,&src,8); | 	compact(&buf,(_double *) &src,8); | ||||||
|  | 	return *(_double *) &src; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -15,6 +15,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "FP_trap.h" | #include "FP_trap.h" | ||||||
| #include "FP_types.h" | #include "FP_types.h" | ||||||
|  | #include "FP_shift.h" | ||||||
| 
 | 
 | ||||||
| long | long | ||||||
| cfi(ds,ss,src) | cfi(ds,ss,src) | ||||||
|  | @ -24,21 +25,25 @@ _double	src;	/* assume worst case */ | ||||||
| { | { | ||||||
| 	EXTEND	buf; | 	EXTEND	buf; | ||||||
| 	long	new; | 	long	new; | ||||||
| 	short	newint,	max_exp; | 	short	max_exp; | ||||||
| 
 | 
 | ||||||
| 	extend(&src,&buf,ss);	/* get extended format */ | 	extend(&src,&buf,ss);	/* get extended format */ | ||||||
| 	buf.exp--;		/* additional bias correction */ | 	if (buf.exp < 0) {	/* no conversion needed */ | ||||||
| 	if (buf.exp < 1) {	/* no conversion needed */ |  | ||||||
| 		src.__double[ss == 8] = 0L; | 		src.__double[ss == 8] = 0L; | ||||||
| 		return(0L); | 		return(0L); | ||||||
| 	} | 	} | ||||||
| 	max_exp = (ds << 3) - 1;	/* signed numbers */ | 	max_exp = (ds << 3) - 2;	/* signed numbers */ | ||||||
| 				/* have more limited max_exp */ | 				/* have more limited max_exp */ | ||||||
| 	if (buf.exp > max_exp) { | 	if (buf.exp > max_exp) { | ||||||
| 		trap(EIOVFL);	/* integer overflow	*/ | 		if (buf.exp == max_exp+1 && buf.sign && buf.m1 == NORMBIT && | ||||||
| 		buf.exp %= max_exp; /* truncate	*/ | 		    buf.m2 == 0L) { | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			trap(EIOVFL);	/* integer overflow	*/ | ||||||
|  | 			buf.exp %= max_exp; /* truncate	*/ | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 	new = buf.m1 >> (32-buf.exp); | 	new = buf.m1 >> (31-buf.exp); | ||||||
| 	if (buf.sign) | 	if (buf.sign) | ||||||
| 		new = -new; | 		new = -new; | ||||||
| done: | done: | ||||||
|  |  | ||||||
|  | @ -27,17 +27,16 @@ _double	src;	/* assume worst case */ | ||||||
| 	short	newint, max_exp; | 	short	newint, max_exp; | ||||||
| 
 | 
 | ||||||
| 	extend(&src,&buf,ss);	/* get extended format	*/ | 	extend(&src,&buf,ss);	/* get extended format	*/ | ||||||
| 	buf.exp--;		/* additional bias correction */ | 	if (buf.exp < 0) {	/* no conversion needed	*/ | ||||||
| 	if (buf.exp < 1) {	/* no conversion needed	*/ |  | ||||||
| 		src.__double[ss == 8] = 0L; | 		src.__double[ss == 8] = 0L; | ||||||
| 		return(0L); | 		return(0L); | ||||||
| 	} | 	} | ||||||
| 	max_exp = (ds << 3); | 	max_exp = (ds << 3) - 1; | ||||||
| 	if (buf.exp > max_exp) { | 	if (buf.exp > max_exp) { | ||||||
| 		trap(EIOVFL);	/* integer overflow	*/ | 		trap(EIOVFL);	/* integer overflow	*/ | ||||||
| 		buf.exp %= max_exp; | 		buf.exp %= max_exp; | ||||||
| 	} | 	} | ||||||
| 	new = buf.m1 >> (32-buf.exp); | 	new = buf.m1 >> (31-buf.exp); | ||||||
| done: | done: | ||||||
| 	src.__double[ss == 8] = new; | 	src.__double[ss == 8] = new; | ||||||
| 	return(new); | 	return(new); | ||||||
|  |  | ||||||
|  | @ -28,14 +28,14 @@ long	src;	/* largest possible integer to convert */ | ||||||
| 
 | 
 | ||||||
| 	zrf_ext(&buf); | 	zrf_ext(&buf); | ||||||
| 	if (ss == sizeof(long))	{ | 	if (ss == sizeof(long))	{ | ||||||
| 		buf.exp = 33; | 		buf.exp = 31; | ||||||
| 		i_src = src; | 		i_src = src; | ||||||
| 		result = (_float *) &src; | 		result = (_float *) &src; | ||||||
| 	} | 	} | ||||||
| 	else	{ | 	else	{ | ||||||
| 		ipt = (short *) &src; | 		ipt = (short *) &src; | ||||||
| 		i_src = (long) *ipt; | 		i_src = (long) *ipt; | ||||||
| 		buf.exp = 17; | 		buf.exp = 15; | ||||||
| 		result = (_float *) &ss; | 		result = (_float *) &ss; | ||||||
| 	} | 	} | ||||||
| 	if (i_src == 0)	{ | 	if (i_src == 0)	{ | ||||||
|  |  | ||||||
|  | @ -29,13 +29,13 @@ long	src;	/* largest possible integer to convert */ | ||||||
| 	result = (_double *) &ss;	/* always */ | 	result = (_double *) &ss;	/* always */ | ||||||
| 	zrf_ext(&buf); | 	zrf_ext(&buf); | ||||||
| 	if (ss == sizeof(long))	{ | 	if (ss == sizeof(long))	{ | ||||||
| 		buf.exp = 33; | 		buf.exp = 31; | ||||||
| 		i_src = src; | 		i_src = src; | ||||||
| 	} | 	} | ||||||
| 	else	{ | 	else	{ | ||||||
| 		ipt = (short *) &src; | 		ipt = (short *) &src; | ||||||
| 		i_src = (long) *ipt; | 		i_src = (long) *ipt; | ||||||
| 		buf.exp = 17; | 		buf.exp = 15; | ||||||
| 	} | 	} | ||||||
| 	if (i_src == 0)	{ | 	if (i_src == 0)	{ | ||||||
| 		zrf8(result); | 		zrf8(result); | ||||||
|  |  | ||||||
|  | @ -12,6 +12,7 @@ | ||||||
| #include	"FP_types.h" | #include	"FP_types.h" | ||||||
| #include	"get_put.h" | #include	"get_put.h" | ||||||
| 
 | 
 | ||||||
|  | int | ||||||
| cmf4(f1,f2) | cmf4(f1,f2) | ||||||
| _float	f1,f2; | _float	f1,f2; | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -34,14 +34,13 @@ _double	d1,d2; | ||||||
| 		rv = l1 < l2 ? 1 : -1; | 		rv = l1 < l2 ? 1 : -1; | ||||||
| 	} | 	} | ||||||
| 	else	{ 		/* decide in 2nd half */ | 	else	{ 		/* decide in 2nd half */ | ||||||
| 		l1 = get4(((char *)&d1 + 4)); | 		unsigned long u1, u2; | ||||||
| 		l2 = get4(((char *)&d2 + 4)); | 		u1 = get4(((char *)&d1 + 4)); | ||||||
| 		if (l1 == l2) | 		u2 = get4(((char *)&d2 + 4)); | ||||||
|  | 		if (u1 == u2) | ||||||
| 			return(0); | 			return(0); | ||||||
| 		if (l1 >= 0) | 		if (u1 < u2) rv = 1; | ||||||
| 			rv = l1 < l2 || l2 < 0 ? 1 : -1; | 		else rv = -1; | ||||||
| 		else if (l2 >= 0) rv = -1; |  | ||||||
| 		else rv = l1 < l2 ? 1 : -1; |  | ||||||
| 	} | 	} | ||||||
| 	return sign1 * rv; | 	return sign1 * rv; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -35,18 +35,19 @@ int	size; | ||||||
| 		f->exp += DBL_BIAS;	/* restore proper bias	*/ | 		f->exp += DBL_BIAS;	/* restore proper bias	*/ | ||||||
| 		if (f->exp > DBL_MAX)	{ | 		if (f->exp > DBL_MAX)	{ | ||||||
| dbl_over:			trap(EFOVFL); | dbl_over:			trap(EFOVFL); | ||||||
| 			f->exp = DBL_MAX; | 			f->exp = DBL_MAX+1; | ||||||
| 			f->m1 = 0xffffffffL; | 			f->m1 = 0; | ||||||
| 			f->m2 = DBL_ZERO; | 			f->m2 = 0; | ||||||
| 			if (error++) | 			if (error++) | ||||||
| 				return; | 				return; | ||||||
| 		} | 		} | ||||||
| 		else if (f->exp < DBL_MIN)	{ | 		else if (f->exp < DBL_MIN)	{ | ||||||
| 			trap(EFUNFL); | 			b64_rsft(&(f->m1)); | ||||||
| 			f->exp = DBL_MIN; | 			if (f->exp < 0) { | ||||||
| 			f->m1 = f->m2 = 0L; | 				b64_sft(&(f->m1), -f->exp); | ||||||
| 			if (error++) | 				f->exp = 0; | ||||||
| 				return; | 			} | ||||||
|  | 			/* underflow ??? */ | ||||||
| 		} | 		} | ||||||
| 			 | 			 | ||||||
| 		/* local CAST conversion		*/ | 		/* local CAST conversion		*/ | ||||||
|  | @ -121,18 +122,19 @@ dbl_over:			trap(EFOVFL); | ||||||
| 		f->exp += SGL_BIAS;	/* restore bias	*/ | 		f->exp += SGL_BIAS;	/* restore bias	*/ | ||||||
| 		if (f->exp > SGL_MAX)	{ | 		if (f->exp > SGL_MAX)	{ | ||||||
| sgl_over:			trap(EFOVFL); | sgl_over:			trap(EFOVFL); | ||||||
| 			f->exp = SGL_MAX; | 			f->exp = SGL_MAX+1; | ||||||
| 			f->m1 = SGL_ZERO; | 			f->m1 = 0L; | ||||||
| 			f->m2 = 0L; | 			f->m2 = 0L; | ||||||
| 			if (error++) | 			if (error++) | ||||||
| 				return; | 				return; | ||||||
| 		} | 		} | ||||||
| 		else if (f->exp < SGL_MIN)	{ | 		else if (f->exp < SGL_MIN)	{ | ||||||
| 			trap(EFUNFL); | 			b64_rsft(&(f->m1)); | ||||||
| 			f->exp = SGL_MIN; | 			if (f->exp < 0) { | ||||||
| 			f->m1 = f->m2 = 0L; | 				b64_sft(&(f->m1), -f->exp); | ||||||
| 			if (error++) | 				f->exp = 0; | ||||||
| 				return; | 			} | ||||||
|  | 			/* underflow ??? */ | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		/* shift mantissa and store	*/ | 		/* shift mantissa and store	*/ | ||||||
|  |  | ||||||
|  | @ -28,14 +28,14 @@ long	src;	/* largest possible integer to convert */ | ||||||
| 
 | 
 | ||||||
| 	zrf_ext(&buf); | 	zrf_ext(&buf); | ||||||
| 	if (ss == sizeof(long))	{ | 	if (ss == sizeof(long))	{ | ||||||
| 		buf.exp = 33; | 		buf.exp = 31; | ||||||
| 		i_src = src; | 		i_src = src; | ||||||
| 		result = (_float *) &src; | 		result = (_float *) &src; | ||||||
| 	} | 	} | ||||||
| 	else	{ | 	else	{ | ||||||
| 		ipt = (short *) &src; | 		ipt = (short *) &src; | ||||||
| 		i_src = (long) *ipt; | 		i_src = (long) *ipt; | ||||||
| 		buf.exp = 17; | 		buf.exp = 15; | ||||||
| 		result = (_float *) &ss; | 		result = (_float *) &ss; | ||||||
| 	} | 	} | ||||||
| 	if (i_src == 0)	{ | 	if (i_src == 0)	{ | ||||||
|  |  | ||||||
|  | @ -16,6 +16,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "FP_types.h" | #include "FP_types.h" | ||||||
| 
 | 
 | ||||||
|  | _double | ||||||
| cuf8(ss,src) | cuf8(ss,src) | ||||||
| int	ss;	/* source size */ | int	ss;	/* source size */ | ||||||
| long	src;	/* largest possible integer to convert */ | long	src;	/* largest possible integer to convert */ | ||||||
|  | @ -26,13 +27,13 @@ long	src;	/* largest possible integer to convert */ | ||||||
| 
 | 
 | ||||||
| 	zrf_ext(&buf); | 	zrf_ext(&buf); | ||||||
| 	if (ss == sizeof(long))	{ | 	if (ss == sizeof(long))	{ | ||||||
| 		buf.exp = 33; | 		buf.exp = 31; | ||||||
| 		i_src = src; | 		i_src = src; | ||||||
| 	} | 	} | ||||||
| 	else	{ | 	else	{ | ||||||
| 		ipt = (short *) &src; | 		ipt = (short *) &src; | ||||||
| 		i_src = (long) *ipt; | 		i_src = (long) *ipt; | ||||||
| 		buf.exp = 17; | 		buf.exp = 15; | ||||||
| 	} | 	} | ||||||
| 	if (i_src == 0)	{ | 	if (i_src == 0)	{ | ||||||
| 		zrf8(&ss); | 		zrf8(&ss); | ||||||
|  | @ -50,4 +51,5 @@ long	src;	/* largest possible integer to convert */ | ||||||
| 			/* adjust mantissa field	*/ | 			/* adjust mantissa field	*/ | ||||||
| 	nrm_ext(&buf); | 	nrm_ext(&buf); | ||||||
| 	compact(&buf,(_double *) &ss,8); | 	compact(&buf,(_double *) &ss,8); | ||||||
|  | 	return *((_double *) &ss); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -68,25 +68,6 @@ EXTEND	*e1,*e2; | ||||||
| 	/*	check for underflow, divide by zero, etc	*/ | 	/*	check for underflow, divide by zero, etc	*/ | ||||||
| 	e1->sign ^= e2->sign; | 	e1->sign ^= e2->sign; | ||||||
| 	e1->exp -= e2->exp; | 	e1->exp -= e2->exp; | ||||||
| 	e1->exp += 2;		/* bias correction	*/ |  | ||||||
| 	if (e1->exp < EXT_MIN)	{ |  | ||||||
| 		/*
 |  | ||||||
| 		 * Exception 8.4 - Underflow |  | ||||||
| 		 */ |  | ||||||
| 		trap(EFUNFL);	/* underflow */ |  | ||||||
| 		e1->exp = EXT_MIN; |  | ||||||
| 		e1->m1 = e1->m2 = 0L; |  | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
| 	if (e1->exp >= EXT_MAX) { |  | ||||||
|                 /*
 |  | ||||||
|                  * Exception 8.3 - Overflow |  | ||||||
|                  */ |  | ||||||
|                 trap(EFOVFL);   /* overflow */ |  | ||||||
|                 e1->exp = EXT_MAX; |  | ||||||
|                 e1->m1 = e1->m2 = 0L; |  | ||||||
|                 return; |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
| #ifndef USE_DIVIDE | #ifndef USE_DIVIDE | ||||||
| 		/* do division of mantissas	*/ | 		/* do division of mantissas	*/ | ||||||
|  | @ -264,4 +245,22 @@ EXTEND	*e1,*e2; | ||||||
| 	e1->m2 = result[1]; | 	e1->m2 = result[1]; | ||||||
| 
 | 
 | ||||||
| 	nrm_ext(e1); | 	nrm_ext(e1); | ||||||
|  | 	if (e1->exp < EXT_MIN)	{ | ||||||
|  | 		/*
 | ||||||
|  | 		 * Exception 8.4 - Underflow | ||||||
|  | 		 */ | ||||||
|  | 		trap(EFUNFL);	/* underflow */ | ||||||
|  | 		e1->exp = EXT_MIN; | ||||||
|  | 		e1->m1 = e1->m2 = 0L; | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 	if (e1->exp >= EXT_MAX) { | ||||||
|  |                 /*
 | ||||||
|  |                  * Exception 8.3 - Overflow | ||||||
|  |                  */ | ||||||
|  |                 trap(EFOVFL);   /* overflow */ | ||||||
|  |                 e1->exp = EXT_MAX; | ||||||
|  |                 e1->m1 = e1->m2 = 0L; | ||||||
|  |                 return; | ||||||
|  |         } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ | ||||||
| 
 | 
 | ||||||
| #include	"FP_types.h" | #include	"FP_types.h" | ||||||
| 
 | 
 | ||||||
|  | _float | ||||||
| dvf4(s2,s1) | dvf4(s2,s1) | ||||||
| _float	s1,s2; | _float	s1,s2; | ||||||
| { | { | ||||||
|  | @ -22,4 +23,5 @@ _float	s1,s2; | ||||||
| 		/* do a divide */ | 		/* do a divide */ | ||||||
| 	div_ext(&e1,&e2); | 	div_ext(&e1,&e2); | ||||||
| 	compact(&e1,(_double *)&s1,sizeof(_float)); | 	compact(&e1,(_double *)&s1,sizeof(_float)); | ||||||
|  | 	return s1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ | ||||||
| 
 | 
 | ||||||
| #include	"FP_types.h" | #include	"FP_types.h" | ||||||
| 
 | 
 | ||||||
|  | _double | ||||||
| dvf8(s2,s1) | dvf8(s2,s1) | ||||||
| _double	s1,s2; | _double	s1,s2; | ||||||
| { | { | ||||||
|  | @ -22,4 +23,5 @@ _double	s1,s2; | ||||||
| 		/* do a divide */ | 		/* do a divide */ | ||||||
| 	div_ext(&e1,&e2); | 	div_ext(&e1,&e2); | ||||||
| 	compact(&e1,&s1,sizeof(_double)); | 	compact(&e1,&s1,sizeof(_double)); | ||||||
|  | 	return s1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -80,6 +80,8 @@ zero:			zrf_ext(to); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	to->m1 |= NORMBIT;				/* set bit L	*/ | 	to->m1 |= NORMBIT;				/* set bit L	*/ | ||||||
| 	if (leadbit == 0)		/* set or clear Leading Bit	*/ | 	if (leadbit == 0) {		/* set or clear Leading Bit	*/ | ||||||
| 		to->m1 &= ~NORMBIT;			/* clear bit L	*/ | 		to->m1 &= ~NORMBIT;			/* clear bit L	*/ | ||||||
|  | 		nrm_ext(to);				/* and normalize */ | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -16,14 +16,17 @@ struct	fef4_returns { | ||||||
| 	_float	f; | 	_float	f; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| fef4(s1) | fef4(r,s1) | ||||||
| _float	s1; | _float	s1; | ||||||
|  | struct fef4_returns	*r; | ||||||
| { | { | ||||||
| 	struct	fef4_returns	*r = (struct fef4_returns *) &s1; |  | ||||||
| 	EXTEND	buf; | 	EXTEND	buf; | ||||||
|  | 	register struct fef4_returns	*p = r;	/* make copy; r might refer
 | ||||||
|  | 						   to itself (see table) | ||||||
|  | 						*/ | ||||||
| 
 | 
 | ||||||
| 	extend((_double *) &s1,&buf,sizeof(_float)); | 	extend((_double *) &s1,&buf,sizeof(_float)); | ||||||
| 	r->e = buf.exp-1; | 	p->e = buf.exp+1; | ||||||
| 	buf.exp = 1; | 	buf.exp = -1; | ||||||
| 	compact(&buf,(_double *) &r->f,sizeof(_float)); | 	compact(&buf,(_double *) &p->f,sizeof(_float)); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -16,14 +16,17 @@ struct	fef8_returns	{ | ||||||
| 	_double	f; | 	_double	f; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| fef8(s1) | fef8(r, s1) | ||||||
| _double	s1; | _double	s1; | ||||||
|  | struct fef8_returns *r; | ||||||
| { | { | ||||||
| 	EXTEND	buf; | 	EXTEND	buf; | ||||||
| 	struct fef8_returns *r = (struct fef8_returns *) &s1; | 	register struct fef8_returns *p = r;	/* make copy, r might refer
 | ||||||
|  | 						   to itself (see table) | ||||||
|  | 						*/ | ||||||
| 
 | 
 | ||||||
| 	extend(&s1,&buf,sizeof(_double)); | 	extend(&s1,&buf,sizeof(_double)); | ||||||
| 	r->e = buf.exp - 1; | 	p->e = buf.exp + 1; | ||||||
| 	buf.exp = 1; | 	buf.exp = -1; | ||||||
| 	compact(&buf,&r->f,sizeof(_double)); | 	compact(&buf,&p->f,sizeof(_double)); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -14,8 +14,14 @@ | ||||||
| 
 | 
 | ||||||
| _float sbf4(); | _float sbf4(); | ||||||
| 
 | 
 | ||||||
| fif4(x,y) | struct fif4_returns { | ||||||
|  | 	_float ipart; | ||||||
|  | 	_float fpart; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | fif4(p,x,y) | ||||||
| _float	x,y; | _float	x,y; | ||||||
|  | struct fif4_returns *p; | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| 	EXTEND	e1,e2; | 	EXTEND	e1,e2; | ||||||
|  | @ -26,19 +32,18 @@ _float	x,y; | ||||||
| 	mul_ext(&e1,&e2); | 	mul_ext(&e1,&e2); | ||||||
| 	e2 = e1; | 	e2 = e1; | ||||||
| 	compact(&e2, (_double *)&y, sizeof(_float)); | 	compact(&e2, (_double *)&y, sizeof(_float)); | ||||||
| 	e1.exp--;			/* additional bias correction */ | 	if (e1.exp < 0) { | ||||||
| 	if (e1.exp < 1) { | 		p->ipart = 0; | ||||||
| 		x = 0; | 		p->fpart = y; | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	if (e1.exp > 31 - SGL_M1LEFT) { | 	if (e1.exp > 30 - SGL_M1LEFT) { | ||||||
| 		x = y; | 		p->ipart = y; | ||||||
| 		y = 0; | 		p->fpart = 0; | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	b64_sft(&e1.m1, 64 - e1.exp); | 	b64_sft(&e1.m1, 64 - e1.exp); | ||||||
| 	b64_sft(&e1.m1, e1.exp - 64);	/* "loose" low order bits */ | 	b64_sft(&e1.m1, e1.exp - 64);	/* "loose" low order bits */ | ||||||
| 	e1.exp++; | 	compact(&e1,(_double *) &(p->ipart), sizeof(SINGLE)); | ||||||
| 	compact(&e1,(_double *) &x, sizeof(SINGLE)); | 	p->fpart = sbf4(p->ipart, y); | ||||||
| 	y = sbf4(x, y); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -14,8 +14,14 @@ | ||||||
| 
 | 
 | ||||||
| _double sbf8(); | _double sbf8(); | ||||||
| 
 | 
 | ||||||
| fif8(x,y) | struct fif8_returns { | ||||||
|  | 	_double	ipart; | ||||||
|  | 	_double fpart; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | fif8(p,x,y) | ||||||
| _double	x,y; | _double	x,y; | ||||||
|  | struct fif8_returns *p; | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| 	EXTEND	e1,e2; | 	EXTEND	e1,e2; | ||||||
|  | @ -26,22 +32,20 @@ _double	x,y; | ||||||
| 	mul_ext(&e1,&e2); | 	mul_ext(&e1,&e2); | ||||||
| 	e2 = e1; | 	e2 = e1; | ||||||
| 	compact(&e2, &y, sizeof(_double)); | 	compact(&e2, &y, sizeof(_double)); | ||||||
| 	e1.exp--;			/* additional bias correction */ | 	if (e1.exp < 0) { | ||||||
| 	if (e1.exp < 1) { | 		p->ipart.__double[0] = 0; | ||||||
| 		x.__double[0] = 0; | 		p->ipart.__double[1] = 0; | ||||||
| 		x.__double[1] = 0; | 		p->fpart = y; | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	if (e1.exp > 63 - DBL_M1LEFT) { | 	if (e1.exp > 62 - DBL_M1LEFT) { | ||||||
| 		x.__double[0] = y.__double[0]; | 		p->ipart = y; | ||||||
| 		x.__double[1] = y.__double[1]; | 		p->fpart.__double[0] = 0; | ||||||
| 		y.__double[0] = 0; | 		p->fpart.__double[1] = 0; | ||||||
| 		y.__double[1] = 0; |  | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	b64_sft(&e1.m1, 64 - e1.exp); | 	b64_sft(&e1.m1, 64 - e1.exp); | ||||||
| 	b64_sft(&e1.m1, e1.exp - 64);	/* "loose" low order bits */ | 	b64_sft(&e1.m1, e1.exp - 64);	/* "loose" low order bits */ | ||||||
| 	e1.exp++; | 	compact(&e1, &(p->ipart), sizeof(DOUBLE)); | ||||||
| 	compact(&e1, &x, sizeof(DOUBLE)); | 	p->fpart = sbf8(p->ipart, y); | ||||||
| 	y = sbf8(x, y); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -13,69 +13,22 @@ | ||||||
| # include "FP_bias.h" | # include "FP_bias.h" | ||||||
| # include "FP_trap.h" | # include "FP_trap.h" | ||||||
| # include "FP_types.h" | # include "FP_types.h" | ||||||
|  | # include "FP_shift.h" | ||||||
| 
 | 
 | ||||||
| mul_ext(e1,e2) | mul_ext(e1,e2) | ||||||
| EXTEND	*e1,*e2; | EXTEND	*e1,*e2; | ||||||
| { | { | ||||||
| 	register int	i,j;		/* loop control	*/ | 	register int	i,j;		/* loop control	*/ | ||||||
| 	short unsigned	mp[4];	/* multiplier */ | 	unsigned short	mp[4];		/* multiplier */ | ||||||
| 	short unsigned	mc[4];	/* multipcand */ | 	unsigned short	mc[4];		/* multipcand */ | ||||||
| 	short unsigned	result[8];	/* result */ | 	unsigned short	result[8];	/* result */ | ||||||
| 	B64		tmp64; |  | ||||||
| 	register unsigned short *pres; | 	register unsigned short *pres; | ||||||
| 
 | 
 | ||||||
| 	/* first save the sign (XOR)			*/ | 	/* first save the sign (XOR)			*/ | ||||||
| 
 |  | ||||||
| 	e1->sign ^= e2->sign; | 	e1->sign ^= e2->sign; | ||||||
| 
 | 
 | ||||||
| 	/********************************************************/ | 	/* compute new exponent */ | ||||||
| 	/* 	 	INCREASE EXPONENT BY ONE (1)	    	*/ | 	e1->exp += e2->exp + 1; | ||||||
| 	/*							*/ |  | ||||||
| 	/* the nature of the multiplication algorithm used	*/ |  | ||||||
| 	/* results in an exponent that is small by an additive	*/ |  | ||||||
| 	/* factor of one (1);					*/ |  | ||||||
| 	/* if the maximum bit is set it will not be subtracted	*/ |  | ||||||
| 	/* during normalization -> this is correct and can be	*/ |  | ||||||
| 	/* expected often with normalized numbers		*/ |  | ||||||
| 	/*	HOWEVER, it is also possible that unnormalized	*/ |  | ||||||
| 	/*	numbers are used. Rather than shifting here	*/ |  | ||||||
| 	/*	always(!) (unless L bit is set) I chose to	*/ |  | ||||||
| 	/*	increase the exponent by one - a simple (FAST)	*/ |  | ||||||
| 	/*	process - and to decrease it later during	*/ |  | ||||||
| 	/*	normalization.					*/ |  | ||||||
| 	/*							*/ |  | ||||||
| 	/********************************************************/ |  | ||||||
| 	/* The effects of bias (as used here)			*/ |  | ||||||
| 	/* and the multiplication algorithm used cancel		*/ |  | ||||||
| 	/* so these statements are commented out		*/ |  | ||||||
| 	/* August 1985 - if changing the Leading Bit (or NORMBIT) */ |  | ||||||
| 	/* this problem with the multiplication algorithm no longer */ |  | ||||||
| 	/* exists - bias must be subtracted now			*/ |  | ||||||
| 	/*							*/ |  | ||||||
| 	/* e1->exp++;						*/ |  | ||||||
| 	/********************************************************/ |  | ||||||
| 
 |  | ||||||
| 	/* next add the exponents			*/ |  | ||||||
| 
 |  | ||||||
| 	e1->exp += e2->exp; |  | ||||||
| 	e1->exp -= 1;			/* correction for bias	*/ |  | ||||||
| 
 |  | ||||||
| 					/* check for overflow	*/ |  | ||||||
| 	if (e1->exp >= EXT_MAX)	{ |  | ||||||
| 		trap(EFOVFL); |  | ||||||
| 			/* if caught 			*/ |  | ||||||
| 			/* return signed infinity	*/ |  | ||||||
| 		e1->exp = EXT_MAX; |  | ||||||
| infinity:	e1->m1 = e1->m2 =0L; |  | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
| 				/* check for underflow	*/ |  | ||||||
| 	if (e1->exp < EXT_MIN)	{ |  | ||||||
| 		trap(EFUNFL); |  | ||||||
| 		e1->exp = EXT_MIN; |  | ||||||
| 		goto infinity; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	/* 128 bit multiply of mantissas			*/ | 	/* 128 bit multiply of mantissas			*/ | ||||||
| 
 | 
 | ||||||
| 		/* assign unknown long formats		*/ | 		/* assign unknown long formats		*/ | ||||||
|  | @ -105,7 +58,15 @@ infinity:	e1->m1 = e1->m2 =0L; | ||||||
| 		} | 		} | ||||||
| 		pres[-1] = k; | 		pres[-1] = k; | ||||||
| 	} | 	} | ||||||
| 	 |         if (! (result[0] & 0x8000)) { | ||||||
|  |                 e1->exp--; | ||||||
|  |                 for (i = 0; i <= 3; i++) { | ||||||
|  |                         result[i] <<= 1; | ||||||
|  |                         if (result[i+1]&0x8000) result[i] |= 1; | ||||||
|  |                 } | ||||||
|  |                 result[4] <<= 1; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
| 	/*
 | 	/*
 | ||||||
| 	 *	combine the registers to a total | 	 *	combine the registers to a total | ||||||
| 	 */ | 	 */ | ||||||
|  | @ -113,8 +74,25 @@ infinity:	e1->m1 = e1->m2 =0L; | ||||||
| 	e1->m2 = ((unsigned long)(result[2]) << 16) + result[3]; | 	e1->m2 = ((unsigned long)(result[2]) << 16) + result[3]; | ||||||
| 	if (result[4] & 0x8000) { | 	if (result[4] & 0x8000) { | ||||||
| 		if (++e1->m2 == 0) | 		if (++e1->m2 == 0) | ||||||
| 			e1->m1++; | 			if (++e1->m1 == 0) { | ||||||
|  | 				e1->m1 = NORMBIT; | ||||||
|  | 				e1->exp++; | ||||||
|  | 			} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	nrm_ext(e1); | 					/* check for overflow	*/ | ||||||
|  | 	if (e1->exp >= EXT_MAX)	{ | ||||||
|  | 		trap(EFOVFL); | ||||||
|  | 			/* if caught 			*/ | ||||||
|  | 			/* return signed infinity	*/ | ||||||
|  | 		e1->exp = EXT_MAX; | ||||||
|  | infinity:	e1->m1 = e1->m2 =0L; | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 				/* check for underflow	*/ | ||||||
|  | 	if (e1->exp < EXT_MIN)	{ | ||||||
|  | 		trap(EFUNFL); | ||||||
|  | 		e1->exp = EXT_MIN; | ||||||
|  | 		goto infinity; | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -16,13 +16,15 @@ | ||||||
| 
 | 
 | ||||||
| #include "FP_types.h" | #include "FP_types.h" | ||||||
| 
 | 
 | ||||||
|  | _float | ||||||
| ngf4(f) | ngf4(f) | ||||||
| _float	f; | _float	f; | ||||||
| { | { | ||||||
| 	char unsigned	*p; | 	unsigned char *p; | ||||||
| 
 | 
 | ||||||
| 	if (f != (_float) 0) { | 	if (f != (_float) 0) { | ||||||
| 		p = (char unsigned *) &f; | 		p = (unsigned char *) &f; | ||||||
| 		*p ^= 0x80; | 		*p ^= 0x80; | ||||||
| 	} | 	} | ||||||
|  | 	return f; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -16,6 +16,7 @@ | ||||||
| 
 | 
 | ||||||
| #include "FP_types.h" | #include "FP_types.h" | ||||||
| 
 | 
 | ||||||
|  | _double | ||||||
| ngf8(f) | ngf8(f) | ||||||
| _double	f; | _double	f; | ||||||
| { | { | ||||||
|  | @ -25,5 +26,5 @@ _double	f; | ||||||
| 		p = (unsigned char *) &f; | 		p = (unsigned char *) &f; | ||||||
| 		*p ^= 0x80; | 		*p ^= 0x80; | ||||||
| 	} | 	} | ||||||
|  | 	return f; | ||||||
| } | } | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -17,16 +17,13 @@ _float | ||||||
| sbf4(s2,s1) | sbf4(s2,s1) | ||||||
| _float	s1,s2; | _float	s1,s2; | ||||||
| { | { | ||||||
| 				/* changing the sign directly	*/ | 	unsigned char *p; | ||||||
| 				/* is faster than the code:	*/ |  | ||||||
| 				/*		s2 = -s2	*/ |  | ||||||
| 	char unsigned *p; |  | ||||||
| 	_float *result = &s1;	/* s1 may not be in a register! */ | 	_float *result = &s1;	/* s1 may not be in a register! */ | ||||||
| 
 | 
 | ||||||
| 	if (s2 == (_float) 0) { | 	if (s2 == (_float) 0) { | ||||||
| 		return s1; | 		return s1; | ||||||
| 	} | 	} | ||||||
| 	p = (char unsigned *) &s2; | 	p = (unsigned char *) &s2; | ||||||
| 	*p ^= 0x80;	/* change sign of s2 */ | 	*p ^= 0x80;	/* change sign of s2 */ | ||||||
| 	*result = adf4(s2,s1); | 	*result = adf4(s2,s1); | ||||||
| 	return(s1);	/* add and return result */ | 	return(s1);	/* add and return result */ | ||||||
|  |  | ||||||
|  | @ -17,16 +17,13 @@ _double | ||||||
| sbf8(s2,s1) | sbf8(s2,s1) | ||||||
| _double	s1,s2; | _double	s1,s2; | ||||||
| { | { | ||||||
| 				/* changing the sign directly	*/ | 	unsigned char *p;		/* sufficient to access sign bit */ | ||||||
| 				/* is faster than the code line	*/ |  | ||||||
| 				/*	s2 = -s2;		*/ |  | ||||||
| 	char unsigned *p;		/* sufficient to access sign bit */ |  | ||||||
| 	_double *result = &s1;	/* s1 may not be in a register! */ | 	_double *result = &s1;	/* s1 may not be in a register! */ | ||||||
| 
 | 
 | ||||||
| 	if (s2.__double[0] == 0 && s2.__double[1] == 0) { | 	if (s2.__double[0] == 0 && s2.__double[1] == 0) { | ||||||
| 		return s1; | 		return s1; | ||||||
| 	} | 	} | ||||||
| 	p = (char unsigned *) &s2; | 	p = (unsigned char *) &s2; | ||||||
| 	*p ^= 0x80;	/* change sign of s2 */ | 	*p ^= 0x80;	/* change sign of s2 */ | ||||||
| 	*result = adf8(s2,s1);	/* add and return result */ | 	*result = adf8(s2,s1);	/* add and return result */ | ||||||
| 	return(s1); | 	return(s1); | ||||||
|  |  | ||||||
|  | @ -10,6 +10,7 @@ | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| #include "FP_types.h" | #include "FP_types.h" | ||||||
|  | 
 | ||||||
| sub_ext(e1,e2) | sub_ext(e1,e2) | ||||||
| EXTEND	*e1,*e2; | EXTEND	*e1,*e2; | ||||||
| { | { | ||||||
|  |  | ||||||
|  | @ -9,8 +9,6 @@ | ||||||
| 	return a zero float (ZRF 4) | 	return a zero float (ZRF 4) | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| #include "FP_types.h" |  | ||||||
| 
 |  | ||||||
| zrf4(l) | zrf4(l) | ||||||
| long	*l; | long	*l; | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue