Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_FS_1_19910112 - c/lib5/math/sign.c
There are 7 other files named sign.c in the archive. Click here to see a list.
/*
 *	+++ NAME +++
 *
 *	 SIGN   Transfer of sign
 *
 *	+++ INDEX +++
 *
 *	 SIGN
 *	 machine independent routines
 *	 math libraries
 *
 *	+++ DESCRIPTION +++
 *
 *	Returns first argument with same sign as second argument.
 *
 *	+++ USAGE +++
 *
 *	 double _sign(x, y)
 *	 double x, y;
 *
 *	+++ PROGRAMMER +++
 *
 *	 Fred Fish
 *	 Goodyear Aerospace Corp, Arizona Div.
 *	 (602) 932-7000 work
 *	 (602) 894-6881 home
 *
 *	---
 */

#include "math.h"
double _sign(x, y)
double x, y;
{
    if (x > 0.0) {
	if (y > 0.0)
	    return x;
	else
	    return -x;
    } else {
	if (y < 0.0)
	    return x;
	else
	    return -x;
    }
}