summaryrefslogtreecommitdiff
path: root/libm/w_cabs.c
blob: 546b6affaf4fa6890390617983788f18840b799b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * cabs() wrapper for hypot().
 *
 * Written by J.T. Conklin, <jtc@wimsey.com>
 * Placed into the Public Domain, 1994.
 */

#include <complex.h>
#include <math.h>

double cabs(double _Complex z)
{
	return hypot(__real__ z, __imag__ z);
}
libm_hidden_def(cabs)

libm_hidden_proto(cabsf)
float cabsf(float _Complex z)
{
	return (float) hypot((double)__real__ z, (double)__imag__ z);
}
libm_hidden_def(cabsf)

#if defined __UCLIBC_HAS_LONG_DOUBLE_MATH__ && !defined __NO_LONG_DOUBLE_MATH
libm_hidden_proto(cabsl)
long double cabsl(long double _Complex z)
{
	return hypotl(__real__ z, __imag__ z);
}
libm_hidden_def(cabsl)
#endif