view Python/hypot.c @ 44156:fb84bd9500a4

Remove special-casing of integer operations, to stop using PyInt_CheckExact.
author Martin v. Löwis <martin@v.loewis.de>
date Tue, 04 Dec 2007 20:34:12 +0000
parents 7bc4cc972b0b
children ef859cd754a7
line wrap: on
line source

/* hypot() replacement */

#include "Python.h"

double hypot(double x, double y)
{
	double yx;

	x = fabs(x);
	y = fabs(y);
	if (x < y) {
		double temp = x;
		x = y;
		y = temp;
	}
	if (x == 0.)
		return 0.;
	else {
		yx = y/x;
		return x*sqrt(1.+yx*yx);
	}
}