File:  [CSRG BSD Unix] / 41BSD / libc / gen / frexp.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:53 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD41
BSD 4.1

/*
	the call
		x = frexp(arg,&exp);
	must return a double fp quantity x which is <1.0
	and the corresponding binary exponent "exp".
	such that
		arg = x*2^exp
*/

double
frexp(x,i)
double x;
int *i;
{
	int neg;
	int j;
	j = 0;
	neg = 0;
	if(x<0){
		x = -x;
		neg = 1;
		}
	if(x>1.0)
		while(x>1){
			j = j+1;
			x = x/2;
			}
	else if(x<0.5)
		while(x<0.5){
			j = j-1;
			x = 2*x;
			}
	*i = j;
	if(neg) x = -x;
	return(x);
	}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.