File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / usr / src / usr.lib / libF77 / cabs.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:28:02 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

/*
 *	"@(#)cabs.c	1.1"
 */
/*
 *	THIS IS STRONGLY BASED ON THE TAHOE FLOATING POINT REPRESENTATION!
 *	The casts are meant to speed things up by avoiding double precision
 *	instructions.
 */

#include <FP.h>

float cabs(real, imag)
float real, imag;
{
float temp;
fortran float sqrt();

if(real < 0)
	((sp_format *)&real)->sign = 0;		/* real = -real; */
if(imag < 0)
	((sp_format *)&imag)->sign = 0;		/* imag = -imag; */
if(imag > real){
	temp = *(float *)&real;
	*(float *)&real = *(float *)&imag;
	*(float *)&imag = temp;
}
if(*(float *)&imag == 0)		/* originally if((real+imag)==real) ! */
	return(*(float *)&real);

temp = (*(float *)&imag)/(*(float *)&real);
temp = (*(float *)&real)*sqrt(1.0 + temp*temp);  /*overflow!!*/
return(temp);
}

unix.superglobalmegacorp.com

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