xref: /netbsd-src/external/gpl2/groff/dist/src/libs/libgroff/hypot.cpp (revision 89a07cf815a29524268025a1139fac4c5190f765)
1*89a07cf8Schristos /*	$NetBSD: hypot.cpp,v 1.1.1.1 2016/01/13 18:41:48 christos Exp $	*/
2*89a07cf8Schristos 
3*89a07cf8Schristos /* Copyright (C) 2005 Free Software Foundation, Inc.
4*89a07cf8Schristos This file is part of the GNU C Library.
5*89a07cf8Schristos 
6*89a07cf8Schristos The GNU C Library is free software; you can redistribute it and/or
7*89a07cf8Schristos modify it under the terms of the GNU Library General Public License as
8*89a07cf8Schristos published by the Free Software Foundation; either version 2 of the
9*89a07cf8Schristos License, or (at your option) any later version.
10*89a07cf8Schristos 
11*89a07cf8Schristos The GNU C Library is distributed in the hope that it will be useful,
12*89a07cf8Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
13*89a07cf8Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*89a07cf8Schristos Library General Public License for more details.
15*89a07cf8Schristos 
16*89a07cf8Schristos You should have received a copy of the GNU Library General Public
17*89a07cf8Schristos License along with the GNU C Library; see the file COPYING.LIB.  If
18*89a07cf8Schristos not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19*89a07cf8Schristos Cambridge, MA 02139, USA.  */
20*89a07cf8Schristos 
21*89a07cf8Schristos #ifdef HAVE_CONFIG_H
22*89a07cf8Schristos #include <config.h>
23*89a07cf8Schristos #endif
24*89a07cf8Schristos 
25*89a07cf8Schristos #include <math.h>
26*89a07cf8Schristos 
27*89a07cf8Schristos #ifdef NEED_DECLARATION_HYPOT
28*89a07cf8Schristos   double hypot(double, double);
29*89a07cf8Schristos #endif /* NEED_DECLARATION_HYPOT */
30*89a07cf8Schristos 
groff_hypot(double x,double y)31*89a07cf8Schristos double groff_hypot(double x, double y)
32*89a07cf8Schristos {
33*89a07cf8Schristos   double result = hypot(x, y);
34*89a07cf8Schristos 
35*89a07cf8Schristos #ifdef __INTERIX
36*89a07cf8Schristos   /* hypot() on Interix is broken */
37*89a07cf8Schristos   if (isnan(result) && !isnan(x) && !isnan(y))
38*89a07cf8Schristos     return 0.0;
39*89a07cf8Schristos #endif
40*89a07cf8Schristos 
41*89a07cf8Schristos   return result;
42*89a07cf8Schristos }
43