xref: /aosp_15_r20/external/libcxx/include/cmath (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===---------------------------- cmath -----------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_CMATH
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_CMATH
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    cmath synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard WorkerMacros:
18*58b9f456SAndroid Build Coastguard Worker
19*58b9f456SAndroid Build Coastguard Worker    HUGE_VAL
20*58b9f456SAndroid Build Coastguard Worker    HUGE_VALF               // C99
21*58b9f456SAndroid Build Coastguard Worker    HUGE_VALL               // C99
22*58b9f456SAndroid Build Coastguard Worker    INFINITY                // C99
23*58b9f456SAndroid Build Coastguard Worker    NAN                     // C99
24*58b9f456SAndroid Build Coastguard Worker    FP_INFINITE             // C99
25*58b9f456SAndroid Build Coastguard Worker    FP_NAN                  // C99
26*58b9f456SAndroid Build Coastguard Worker    FP_NORMAL               // C99
27*58b9f456SAndroid Build Coastguard Worker    FP_SUBNORMAL            // C99
28*58b9f456SAndroid Build Coastguard Worker    FP_ZERO                 // C99
29*58b9f456SAndroid Build Coastguard Worker    FP_FAST_FMA             // C99
30*58b9f456SAndroid Build Coastguard Worker    FP_FAST_FMAF            // C99
31*58b9f456SAndroid Build Coastguard Worker    FP_FAST_FMAL            // C99
32*58b9f456SAndroid Build Coastguard Worker    FP_ILOGB0               // C99
33*58b9f456SAndroid Build Coastguard Worker    FP_ILOGBNAN             // C99
34*58b9f456SAndroid Build Coastguard Worker    MATH_ERRNO              // C99
35*58b9f456SAndroid Build Coastguard Worker    MATH_ERREXCEPT          // C99
36*58b9f456SAndroid Build Coastguard Worker    math_errhandling        // C99
37*58b9f456SAndroid Build Coastguard Worker
38*58b9f456SAndroid Build Coastguard Workernamespace std
39*58b9f456SAndroid Build Coastguard Worker{
40*58b9f456SAndroid Build Coastguard Worker
41*58b9f456SAndroid Build Coastguard WorkerTypes:
42*58b9f456SAndroid Build Coastguard Worker
43*58b9f456SAndroid Build Coastguard Worker    float_t                 // C99
44*58b9f456SAndroid Build Coastguard Worker    double_t                // C99
45*58b9f456SAndroid Build Coastguard Worker
46*58b9f456SAndroid Build Coastguard Worker// C90
47*58b9f456SAndroid Build Coastguard Worker
48*58b9f456SAndroid Build Coastguard Workerfloating_point abs(floating_point x);
49*58b9f456SAndroid Build Coastguard Worker
50*58b9f456SAndroid Build Coastguard Workerfloating_point acos (arithmetic x);
51*58b9f456SAndroid Build Coastguard Workerfloat          acosf(float x);
52*58b9f456SAndroid Build Coastguard Workerlong double    acosl(long double x);
53*58b9f456SAndroid Build Coastguard Worker
54*58b9f456SAndroid Build Coastguard Workerfloating_point asin (arithmetic x);
55*58b9f456SAndroid Build Coastguard Workerfloat          asinf(float x);
56*58b9f456SAndroid Build Coastguard Workerlong double    asinl(long double x);
57*58b9f456SAndroid Build Coastguard Worker
58*58b9f456SAndroid Build Coastguard Workerfloating_point atan (arithmetic x);
59*58b9f456SAndroid Build Coastguard Workerfloat          atanf(float x);
60*58b9f456SAndroid Build Coastguard Workerlong double    atanl(long double x);
61*58b9f456SAndroid Build Coastguard Worker
62*58b9f456SAndroid Build Coastguard Workerfloating_point atan2 (arithmetic y, arithmetic x);
63*58b9f456SAndroid Build Coastguard Workerfloat          atan2f(float y, float x);
64*58b9f456SAndroid Build Coastguard Workerlong double    atan2l(long double y, long double x);
65*58b9f456SAndroid Build Coastguard Worker
66*58b9f456SAndroid Build Coastguard Workerfloating_point ceil (arithmetic x);
67*58b9f456SAndroid Build Coastguard Workerfloat          ceilf(float x);
68*58b9f456SAndroid Build Coastguard Workerlong double    ceill(long double x);
69*58b9f456SAndroid Build Coastguard Worker
70*58b9f456SAndroid Build Coastguard Workerfloating_point cos (arithmetic x);
71*58b9f456SAndroid Build Coastguard Workerfloat          cosf(float x);
72*58b9f456SAndroid Build Coastguard Workerlong double    cosl(long double x);
73*58b9f456SAndroid Build Coastguard Worker
74*58b9f456SAndroid Build Coastguard Workerfloating_point cosh (arithmetic x);
75*58b9f456SAndroid Build Coastguard Workerfloat          coshf(float x);
76*58b9f456SAndroid Build Coastguard Workerlong double    coshl(long double x);
77*58b9f456SAndroid Build Coastguard Worker
78*58b9f456SAndroid Build Coastguard Workerfloating_point exp (arithmetic x);
79*58b9f456SAndroid Build Coastguard Workerfloat          expf(float x);
80*58b9f456SAndroid Build Coastguard Workerlong double    expl(long double x);
81*58b9f456SAndroid Build Coastguard Worker
82*58b9f456SAndroid Build Coastguard Workerfloating_point fabs (arithmetic x);
83*58b9f456SAndroid Build Coastguard Workerfloat          fabsf(float x);
84*58b9f456SAndroid Build Coastguard Workerlong double    fabsl(long double x);
85*58b9f456SAndroid Build Coastguard Worker
86*58b9f456SAndroid Build Coastguard Workerfloating_point floor (arithmetic x);
87*58b9f456SAndroid Build Coastguard Workerfloat          floorf(float x);
88*58b9f456SAndroid Build Coastguard Workerlong double    floorl(long double x);
89*58b9f456SAndroid Build Coastguard Worker
90*58b9f456SAndroid Build Coastguard Workerfloating_point fmod (arithmetic x, arithmetic y);
91*58b9f456SAndroid Build Coastguard Workerfloat          fmodf(float x, float y);
92*58b9f456SAndroid Build Coastguard Workerlong double    fmodl(long double x, long double y);
93*58b9f456SAndroid Build Coastguard Worker
94*58b9f456SAndroid Build Coastguard Workerfloating_point frexp (arithmetic value, int* exp);
95*58b9f456SAndroid Build Coastguard Workerfloat          frexpf(float value, int* exp);
96*58b9f456SAndroid Build Coastguard Workerlong double    frexpl(long double value, int* exp);
97*58b9f456SAndroid Build Coastguard Worker
98*58b9f456SAndroid Build Coastguard Workerfloating_point ldexp (arithmetic value, int exp);
99*58b9f456SAndroid Build Coastguard Workerfloat          ldexpf(float value, int exp);
100*58b9f456SAndroid Build Coastguard Workerlong double    ldexpl(long double value, int exp);
101*58b9f456SAndroid Build Coastguard Worker
102*58b9f456SAndroid Build Coastguard Workerfloating_point log (arithmetic x);
103*58b9f456SAndroid Build Coastguard Workerfloat          logf(float x);
104*58b9f456SAndroid Build Coastguard Workerlong double    logl(long double x);
105*58b9f456SAndroid Build Coastguard Worker
106*58b9f456SAndroid Build Coastguard Workerfloating_point log10 (arithmetic x);
107*58b9f456SAndroid Build Coastguard Workerfloat          log10f(float x);
108*58b9f456SAndroid Build Coastguard Workerlong double    log10l(long double x);
109*58b9f456SAndroid Build Coastguard Worker
110*58b9f456SAndroid Build Coastguard Workerfloating_point modf (floating_point value, floating_point* iptr);
111*58b9f456SAndroid Build Coastguard Workerfloat          modff(float value, float* iptr);
112*58b9f456SAndroid Build Coastguard Workerlong double    modfl(long double value, long double* iptr);
113*58b9f456SAndroid Build Coastguard Worker
114*58b9f456SAndroid Build Coastguard Workerfloating_point pow (arithmetic x, arithmetic y);
115*58b9f456SAndroid Build Coastguard Workerfloat          powf(float x, float y);
116*58b9f456SAndroid Build Coastguard Workerlong double    powl(long double x, long double y);
117*58b9f456SAndroid Build Coastguard Worker
118*58b9f456SAndroid Build Coastguard Workerfloating_point sin (arithmetic x);
119*58b9f456SAndroid Build Coastguard Workerfloat          sinf(float x);
120*58b9f456SAndroid Build Coastguard Workerlong double    sinl(long double x);
121*58b9f456SAndroid Build Coastguard Worker
122*58b9f456SAndroid Build Coastguard Workerfloating_point sinh (arithmetic x);
123*58b9f456SAndroid Build Coastguard Workerfloat          sinhf(float x);
124*58b9f456SAndroid Build Coastguard Workerlong double    sinhl(long double x);
125*58b9f456SAndroid Build Coastguard Worker
126*58b9f456SAndroid Build Coastguard Workerfloating_point sqrt (arithmetic x);
127*58b9f456SAndroid Build Coastguard Workerfloat          sqrtf(float x);
128*58b9f456SAndroid Build Coastguard Workerlong double    sqrtl(long double x);
129*58b9f456SAndroid Build Coastguard Worker
130*58b9f456SAndroid Build Coastguard Workerfloating_point tan (arithmetic x);
131*58b9f456SAndroid Build Coastguard Workerfloat          tanf(float x);
132*58b9f456SAndroid Build Coastguard Workerlong double    tanl(long double x);
133*58b9f456SAndroid Build Coastguard Worker
134*58b9f456SAndroid Build Coastguard Workerfloating_point tanh (arithmetic x);
135*58b9f456SAndroid Build Coastguard Workerfloat          tanhf(float x);
136*58b9f456SAndroid Build Coastguard Workerlong double    tanhl(long double x);
137*58b9f456SAndroid Build Coastguard Worker
138*58b9f456SAndroid Build Coastguard Worker//  C99
139*58b9f456SAndroid Build Coastguard Worker
140*58b9f456SAndroid Build Coastguard Workerbool signbit(arithmetic x);
141*58b9f456SAndroid Build Coastguard Worker
142*58b9f456SAndroid Build Coastguard Workerint fpclassify(arithmetic x);
143*58b9f456SAndroid Build Coastguard Worker
144*58b9f456SAndroid Build Coastguard Workerbool isfinite(arithmetic x);
145*58b9f456SAndroid Build Coastguard Workerbool isinf(arithmetic x);
146*58b9f456SAndroid Build Coastguard Workerbool isnan(arithmetic x);
147*58b9f456SAndroid Build Coastguard Workerbool isnormal(arithmetic x);
148*58b9f456SAndroid Build Coastguard Worker
149*58b9f456SAndroid Build Coastguard Workerbool isgreater(arithmetic x, arithmetic y);
150*58b9f456SAndroid Build Coastguard Workerbool isgreaterequal(arithmetic x, arithmetic y);
151*58b9f456SAndroid Build Coastguard Workerbool isless(arithmetic x, arithmetic y);
152*58b9f456SAndroid Build Coastguard Workerbool islessequal(arithmetic x, arithmetic y);
153*58b9f456SAndroid Build Coastguard Workerbool islessgreater(arithmetic x, arithmetic y);
154*58b9f456SAndroid Build Coastguard Workerbool isunordered(arithmetic x, arithmetic y);
155*58b9f456SAndroid Build Coastguard Worker
156*58b9f456SAndroid Build Coastguard Workerfloating_point acosh (arithmetic x);
157*58b9f456SAndroid Build Coastguard Workerfloat          acoshf(float x);
158*58b9f456SAndroid Build Coastguard Workerlong double    acoshl(long double x);
159*58b9f456SAndroid Build Coastguard Worker
160*58b9f456SAndroid Build Coastguard Workerfloating_point asinh (arithmetic x);
161*58b9f456SAndroid Build Coastguard Workerfloat          asinhf(float x);
162*58b9f456SAndroid Build Coastguard Workerlong double    asinhl(long double x);
163*58b9f456SAndroid Build Coastguard Worker
164*58b9f456SAndroid Build Coastguard Workerfloating_point atanh (arithmetic x);
165*58b9f456SAndroid Build Coastguard Workerfloat          atanhf(float x);
166*58b9f456SAndroid Build Coastguard Workerlong double    atanhl(long double x);
167*58b9f456SAndroid Build Coastguard Worker
168*58b9f456SAndroid Build Coastguard Workerfloating_point cbrt (arithmetic x);
169*58b9f456SAndroid Build Coastguard Workerfloat          cbrtf(float x);
170*58b9f456SAndroid Build Coastguard Workerlong double    cbrtl(long double x);
171*58b9f456SAndroid Build Coastguard Worker
172*58b9f456SAndroid Build Coastguard Workerfloating_point copysign (arithmetic x, arithmetic y);
173*58b9f456SAndroid Build Coastguard Workerfloat          copysignf(float x, float y);
174*58b9f456SAndroid Build Coastguard Workerlong double    copysignl(long double x, long double y);
175*58b9f456SAndroid Build Coastguard Worker
176*58b9f456SAndroid Build Coastguard Workerfloating_point erf (arithmetic x);
177*58b9f456SAndroid Build Coastguard Workerfloat          erff(float x);
178*58b9f456SAndroid Build Coastguard Workerlong double    erfl(long double x);
179*58b9f456SAndroid Build Coastguard Worker
180*58b9f456SAndroid Build Coastguard Workerfloating_point erfc (arithmetic x);
181*58b9f456SAndroid Build Coastguard Workerfloat          erfcf(float x);
182*58b9f456SAndroid Build Coastguard Workerlong double    erfcl(long double x);
183*58b9f456SAndroid Build Coastguard Worker
184*58b9f456SAndroid Build Coastguard Workerfloating_point exp2 (arithmetic x);
185*58b9f456SAndroid Build Coastguard Workerfloat          exp2f(float x);
186*58b9f456SAndroid Build Coastguard Workerlong double    exp2l(long double x);
187*58b9f456SAndroid Build Coastguard Worker
188*58b9f456SAndroid Build Coastguard Workerfloating_point expm1 (arithmetic x);
189*58b9f456SAndroid Build Coastguard Workerfloat          expm1f(float x);
190*58b9f456SAndroid Build Coastguard Workerlong double    expm1l(long double x);
191*58b9f456SAndroid Build Coastguard Worker
192*58b9f456SAndroid Build Coastguard Workerfloating_point fdim (arithmetic x, arithmetic y);
193*58b9f456SAndroid Build Coastguard Workerfloat          fdimf(float x, float y);
194*58b9f456SAndroid Build Coastguard Workerlong double    fdiml(long double x, long double y);
195*58b9f456SAndroid Build Coastguard Worker
196*58b9f456SAndroid Build Coastguard Workerfloating_point fma (arithmetic x, arithmetic y, arithmetic z);
197*58b9f456SAndroid Build Coastguard Workerfloat          fmaf(float x, float y, float z);
198*58b9f456SAndroid Build Coastguard Workerlong double    fmal(long double x, long double y, long double z);
199*58b9f456SAndroid Build Coastguard Worker
200*58b9f456SAndroid Build Coastguard Workerfloating_point fmax (arithmetic x, arithmetic y);
201*58b9f456SAndroid Build Coastguard Workerfloat          fmaxf(float x, float y);
202*58b9f456SAndroid Build Coastguard Workerlong double    fmaxl(long double x, long double y);
203*58b9f456SAndroid Build Coastguard Worker
204*58b9f456SAndroid Build Coastguard Workerfloating_point fmin (arithmetic x, arithmetic y);
205*58b9f456SAndroid Build Coastguard Workerfloat          fminf(float x, float y);
206*58b9f456SAndroid Build Coastguard Workerlong double    fminl(long double x, long double y);
207*58b9f456SAndroid Build Coastguard Worker
208*58b9f456SAndroid Build Coastguard Workerfloating_point hypot (arithmetic x, arithmetic y);
209*58b9f456SAndroid Build Coastguard Workerfloat          hypotf(float x, float y);
210*58b9f456SAndroid Build Coastguard Workerlong double    hypotl(long double x, long double y);
211*58b9f456SAndroid Build Coastguard Worker
212*58b9f456SAndroid Build Coastguard Workerdouble       hypot(double x, double y, double z);                // C++17
213*58b9f456SAndroid Build Coastguard Workerfloat        hypot(float x, float y, float z);                   // C++17
214*58b9f456SAndroid Build Coastguard Workerlong double  hypot(long double x, long double y, long double z); // C++17
215*58b9f456SAndroid Build Coastguard Worker
216*58b9f456SAndroid Build Coastguard Workerint ilogb (arithmetic x);
217*58b9f456SAndroid Build Coastguard Workerint ilogbf(float x);
218*58b9f456SAndroid Build Coastguard Workerint ilogbl(long double x);
219*58b9f456SAndroid Build Coastguard Worker
220*58b9f456SAndroid Build Coastguard Workerfloating_point lgamma (arithmetic x);
221*58b9f456SAndroid Build Coastguard Workerfloat          lgammaf(float x);
222*58b9f456SAndroid Build Coastguard Workerlong double    lgammal(long double x);
223*58b9f456SAndroid Build Coastguard Worker
224*58b9f456SAndroid Build Coastguard Workerlong long llrint (arithmetic x);
225*58b9f456SAndroid Build Coastguard Workerlong long llrintf(float x);
226*58b9f456SAndroid Build Coastguard Workerlong long llrintl(long double x);
227*58b9f456SAndroid Build Coastguard Worker
228*58b9f456SAndroid Build Coastguard Workerlong long llround (arithmetic x);
229*58b9f456SAndroid Build Coastguard Workerlong long llroundf(float x);
230*58b9f456SAndroid Build Coastguard Workerlong long llroundl(long double x);
231*58b9f456SAndroid Build Coastguard Worker
232*58b9f456SAndroid Build Coastguard Workerfloating_point log1p (arithmetic x);
233*58b9f456SAndroid Build Coastguard Workerfloat          log1pf(float x);
234*58b9f456SAndroid Build Coastguard Workerlong double    log1pl(long double x);
235*58b9f456SAndroid Build Coastguard Worker
236*58b9f456SAndroid Build Coastguard Workerfloating_point log2 (arithmetic x);
237*58b9f456SAndroid Build Coastguard Workerfloat          log2f(float x);
238*58b9f456SAndroid Build Coastguard Workerlong double    log2l(long double x);
239*58b9f456SAndroid Build Coastguard Worker
240*58b9f456SAndroid Build Coastguard Workerfloating_point logb (arithmetic x);
241*58b9f456SAndroid Build Coastguard Workerfloat          logbf(float x);
242*58b9f456SAndroid Build Coastguard Workerlong double    logbl(long double x);
243*58b9f456SAndroid Build Coastguard Worker
244*58b9f456SAndroid Build Coastguard Workerlong lrint (arithmetic x);
245*58b9f456SAndroid Build Coastguard Workerlong lrintf(float x);
246*58b9f456SAndroid Build Coastguard Workerlong lrintl(long double x);
247*58b9f456SAndroid Build Coastguard Worker
248*58b9f456SAndroid Build Coastguard Workerlong lround (arithmetic x);
249*58b9f456SAndroid Build Coastguard Workerlong lroundf(float x);
250*58b9f456SAndroid Build Coastguard Workerlong lroundl(long double x);
251*58b9f456SAndroid Build Coastguard Worker
252*58b9f456SAndroid Build Coastguard Workerdouble      nan (const char* str);
253*58b9f456SAndroid Build Coastguard Workerfloat       nanf(const char* str);
254*58b9f456SAndroid Build Coastguard Workerlong double nanl(const char* str);
255*58b9f456SAndroid Build Coastguard Worker
256*58b9f456SAndroid Build Coastguard Workerfloating_point nearbyint (arithmetic x);
257*58b9f456SAndroid Build Coastguard Workerfloat          nearbyintf(float x);
258*58b9f456SAndroid Build Coastguard Workerlong double    nearbyintl(long double x);
259*58b9f456SAndroid Build Coastguard Worker
260*58b9f456SAndroid Build Coastguard Workerfloating_point nextafter (arithmetic x, arithmetic y);
261*58b9f456SAndroid Build Coastguard Workerfloat          nextafterf(float x, float y);
262*58b9f456SAndroid Build Coastguard Workerlong double    nextafterl(long double x, long double y);
263*58b9f456SAndroid Build Coastguard Worker
264*58b9f456SAndroid Build Coastguard Workerfloating_point nexttoward (arithmetic x, long double y);
265*58b9f456SAndroid Build Coastguard Workerfloat          nexttowardf(float x, long double y);
266*58b9f456SAndroid Build Coastguard Workerlong double    nexttowardl(long double x, long double y);
267*58b9f456SAndroid Build Coastguard Worker
268*58b9f456SAndroid Build Coastguard Workerfloating_point remainder (arithmetic x, arithmetic y);
269*58b9f456SAndroid Build Coastguard Workerfloat          remainderf(float x, float y);
270*58b9f456SAndroid Build Coastguard Workerlong double    remainderl(long double x, long double y);
271*58b9f456SAndroid Build Coastguard Worker
272*58b9f456SAndroid Build Coastguard Workerfloating_point remquo (arithmetic x, arithmetic y, int* pquo);
273*58b9f456SAndroid Build Coastguard Workerfloat          remquof(float x, float y, int* pquo);
274*58b9f456SAndroid Build Coastguard Workerlong double    remquol(long double x, long double y, int* pquo);
275*58b9f456SAndroid Build Coastguard Worker
276*58b9f456SAndroid Build Coastguard Workerfloating_point rint (arithmetic x);
277*58b9f456SAndroid Build Coastguard Workerfloat          rintf(float x);
278*58b9f456SAndroid Build Coastguard Workerlong double    rintl(long double x);
279*58b9f456SAndroid Build Coastguard Worker
280*58b9f456SAndroid Build Coastguard Workerfloating_point round (arithmetic x);
281*58b9f456SAndroid Build Coastguard Workerfloat          roundf(float x);
282*58b9f456SAndroid Build Coastguard Workerlong double    roundl(long double x);
283*58b9f456SAndroid Build Coastguard Worker
284*58b9f456SAndroid Build Coastguard Workerfloating_point scalbln (arithmetic x, long ex);
285*58b9f456SAndroid Build Coastguard Workerfloat          scalblnf(float x, long ex);
286*58b9f456SAndroid Build Coastguard Workerlong double    scalblnl(long double x, long ex);
287*58b9f456SAndroid Build Coastguard Worker
288*58b9f456SAndroid Build Coastguard Workerfloating_point scalbn (arithmetic x, int ex);
289*58b9f456SAndroid Build Coastguard Workerfloat          scalbnf(float x, int ex);
290*58b9f456SAndroid Build Coastguard Workerlong double    scalbnl(long double x, int ex);
291*58b9f456SAndroid Build Coastguard Worker
292*58b9f456SAndroid Build Coastguard Workerfloating_point tgamma (arithmetic x);
293*58b9f456SAndroid Build Coastguard Workerfloat          tgammaf(float x);
294*58b9f456SAndroid Build Coastguard Workerlong double    tgammal(long double x);
295*58b9f456SAndroid Build Coastguard Worker
296*58b9f456SAndroid Build Coastguard Workerfloating_point trunc (arithmetic x);
297*58b9f456SAndroid Build Coastguard Workerfloat          truncf(float x);
298*58b9f456SAndroid Build Coastguard Workerlong double    truncl(long double x);
299*58b9f456SAndroid Build Coastguard Worker
300*58b9f456SAndroid Build Coastguard Worker}  // std
301*58b9f456SAndroid Build Coastguard Worker
302*58b9f456SAndroid Build Coastguard Worker*/
303*58b9f456SAndroid Build Coastguard Worker
304*58b9f456SAndroid Build Coastguard Worker#include <__config>
305*58b9f456SAndroid Build Coastguard Worker#include <math.h>
306*58b9f456SAndroid Build Coastguard Worker#include <version>
307*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
308*58b9f456SAndroid Build Coastguard Worker
309*58b9f456SAndroid Build Coastguard Worker#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
310*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
311*58b9f456SAndroid Build Coastguard Worker#endif
312*58b9f456SAndroid Build Coastguard Worker
313*58b9f456SAndroid Build Coastguard Worker_LIBCPP_PUSH_MACROS
314*58b9f456SAndroid Build Coastguard Worker#include <__undef_macros>
315*58b9f456SAndroid Build Coastguard Worker
316*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
317*58b9f456SAndroid Build Coastguard Worker
318*58b9f456SAndroid Build Coastguard Workerusing ::signbit;
319*58b9f456SAndroid Build Coastguard Workerusing ::fpclassify;
320*58b9f456SAndroid Build Coastguard Workerusing ::isfinite;
321*58b9f456SAndroid Build Coastguard Workerusing ::isinf;
322*58b9f456SAndroid Build Coastguard Workerusing ::isnan;
323*58b9f456SAndroid Build Coastguard Workerusing ::isnormal;
324*58b9f456SAndroid Build Coastguard Workerusing ::isgreater;
325*58b9f456SAndroid Build Coastguard Workerusing ::isgreaterequal;
326*58b9f456SAndroid Build Coastguard Workerusing ::isless;
327*58b9f456SAndroid Build Coastguard Workerusing ::islessequal;
328*58b9f456SAndroid Build Coastguard Workerusing ::islessgreater;
329*58b9f456SAndroid Build Coastguard Workerusing ::isunordered;
330*58b9f456SAndroid Build Coastguard Workerusing ::isunordered;
331*58b9f456SAndroid Build Coastguard Worker
332*58b9f456SAndroid Build Coastguard Workerusing ::float_t;
333*58b9f456SAndroid Build Coastguard Workerusing ::double_t;
334*58b9f456SAndroid Build Coastguard Worker
335*58b9f456SAndroid Build Coastguard Worker#ifndef _AIX
336*58b9f456SAndroid Build Coastguard Workerusing ::abs;
337*58b9f456SAndroid Build Coastguard Worker#endif
338*58b9f456SAndroid Build Coastguard Worker
339*58b9f456SAndroid Build Coastguard Workerusing ::acos;
340*58b9f456SAndroid Build Coastguard Workerusing ::acosf;
341*58b9f456SAndroid Build Coastguard Workerusing ::asin;
342*58b9f456SAndroid Build Coastguard Workerusing ::asinf;
343*58b9f456SAndroid Build Coastguard Workerusing ::atan;
344*58b9f456SAndroid Build Coastguard Workerusing ::atanf;
345*58b9f456SAndroid Build Coastguard Workerusing ::atan2;
346*58b9f456SAndroid Build Coastguard Workerusing ::atan2f;
347*58b9f456SAndroid Build Coastguard Workerusing ::ceil;
348*58b9f456SAndroid Build Coastguard Workerusing ::ceilf;
349*58b9f456SAndroid Build Coastguard Workerusing ::cos;
350*58b9f456SAndroid Build Coastguard Workerusing ::cosf;
351*58b9f456SAndroid Build Coastguard Workerusing ::cosh;
352*58b9f456SAndroid Build Coastguard Workerusing ::coshf;
353*58b9f456SAndroid Build Coastguard Worker
354*58b9f456SAndroid Build Coastguard Workerusing ::exp;
355*58b9f456SAndroid Build Coastguard Workerusing ::expf;
356*58b9f456SAndroid Build Coastguard Worker
357*58b9f456SAndroid Build Coastguard Workerusing ::fabs;
358*58b9f456SAndroid Build Coastguard Workerusing ::fabsf;
359*58b9f456SAndroid Build Coastguard Workerusing ::floor;
360*58b9f456SAndroid Build Coastguard Workerusing ::floorf;
361*58b9f456SAndroid Build Coastguard Worker
362*58b9f456SAndroid Build Coastguard Workerusing ::fmod;
363*58b9f456SAndroid Build Coastguard Workerusing ::fmodf;
364*58b9f456SAndroid Build Coastguard Worker
365*58b9f456SAndroid Build Coastguard Workerusing ::frexp;
366*58b9f456SAndroid Build Coastguard Workerusing ::frexpf;
367*58b9f456SAndroid Build Coastguard Workerusing ::ldexp;
368*58b9f456SAndroid Build Coastguard Workerusing ::ldexpf;
369*58b9f456SAndroid Build Coastguard Worker
370*58b9f456SAndroid Build Coastguard Workerusing ::log;
371*58b9f456SAndroid Build Coastguard Workerusing ::logf;
372*58b9f456SAndroid Build Coastguard Worker
373*58b9f456SAndroid Build Coastguard Workerusing ::log10;
374*58b9f456SAndroid Build Coastguard Workerusing ::log10f;
375*58b9f456SAndroid Build Coastguard Workerusing ::modf;
376*58b9f456SAndroid Build Coastguard Workerusing ::modff;
377*58b9f456SAndroid Build Coastguard Worker
378*58b9f456SAndroid Build Coastguard Workerusing ::pow;
379*58b9f456SAndroid Build Coastguard Workerusing ::powf;
380*58b9f456SAndroid Build Coastguard Worker
381*58b9f456SAndroid Build Coastguard Workerusing ::sin;
382*58b9f456SAndroid Build Coastguard Workerusing ::sinf;
383*58b9f456SAndroid Build Coastguard Workerusing ::sinh;
384*58b9f456SAndroid Build Coastguard Workerusing ::sinhf;
385*58b9f456SAndroid Build Coastguard Worker
386*58b9f456SAndroid Build Coastguard Workerusing ::sqrt;
387*58b9f456SAndroid Build Coastguard Workerusing ::sqrtf;
388*58b9f456SAndroid Build Coastguard Workerusing ::tan;
389*58b9f456SAndroid Build Coastguard Workerusing ::tanf;
390*58b9f456SAndroid Build Coastguard Worker
391*58b9f456SAndroid Build Coastguard Workerusing ::tanh;
392*58b9f456SAndroid Build Coastguard Workerusing ::tanhf;
393*58b9f456SAndroid Build Coastguard Worker
394*58b9f456SAndroid Build Coastguard Workerusing ::acosh;
395*58b9f456SAndroid Build Coastguard Workerusing ::acoshf;
396*58b9f456SAndroid Build Coastguard Workerusing ::asinh;
397*58b9f456SAndroid Build Coastguard Workerusing ::asinhf;
398*58b9f456SAndroid Build Coastguard Workerusing ::atanh;
399*58b9f456SAndroid Build Coastguard Workerusing ::atanhf;
400*58b9f456SAndroid Build Coastguard Workerusing ::cbrt;
401*58b9f456SAndroid Build Coastguard Workerusing ::cbrtf;
402*58b9f456SAndroid Build Coastguard Worker
403*58b9f456SAndroid Build Coastguard Workerusing ::copysign;
404*58b9f456SAndroid Build Coastguard Workerusing ::copysignf;
405*58b9f456SAndroid Build Coastguard Worker
406*58b9f456SAndroid Build Coastguard Workerusing ::erf;
407*58b9f456SAndroid Build Coastguard Workerusing ::erff;
408*58b9f456SAndroid Build Coastguard Workerusing ::erfc;
409*58b9f456SAndroid Build Coastguard Workerusing ::erfcf;
410*58b9f456SAndroid Build Coastguard Workerusing ::exp2;
411*58b9f456SAndroid Build Coastguard Workerusing ::exp2f;
412*58b9f456SAndroid Build Coastguard Workerusing ::expm1;
413*58b9f456SAndroid Build Coastguard Workerusing ::expm1f;
414*58b9f456SAndroid Build Coastguard Workerusing ::fdim;
415*58b9f456SAndroid Build Coastguard Workerusing ::fdimf;
416*58b9f456SAndroid Build Coastguard Workerusing ::fmaf;
417*58b9f456SAndroid Build Coastguard Workerusing ::fma;
418*58b9f456SAndroid Build Coastguard Workerusing ::fmax;
419*58b9f456SAndroid Build Coastguard Workerusing ::fmaxf;
420*58b9f456SAndroid Build Coastguard Workerusing ::fmin;
421*58b9f456SAndroid Build Coastguard Workerusing ::fminf;
422*58b9f456SAndroid Build Coastguard Workerusing ::hypot;
423*58b9f456SAndroid Build Coastguard Workerusing ::hypotf;
424*58b9f456SAndroid Build Coastguard Workerusing ::ilogb;
425*58b9f456SAndroid Build Coastguard Workerusing ::ilogbf;
426*58b9f456SAndroid Build Coastguard Workerusing ::lgamma;
427*58b9f456SAndroid Build Coastguard Workerusing ::lgammaf;
428*58b9f456SAndroid Build Coastguard Workerusing ::llrint;
429*58b9f456SAndroid Build Coastguard Workerusing ::llrintf;
430*58b9f456SAndroid Build Coastguard Workerusing ::llround;
431*58b9f456SAndroid Build Coastguard Workerusing ::llroundf;
432*58b9f456SAndroid Build Coastguard Workerusing ::log1p;
433*58b9f456SAndroid Build Coastguard Workerusing ::log1pf;
434*58b9f456SAndroid Build Coastguard Workerusing ::log2;
435*58b9f456SAndroid Build Coastguard Workerusing ::log2f;
436*58b9f456SAndroid Build Coastguard Workerusing ::logb;
437*58b9f456SAndroid Build Coastguard Workerusing ::logbf;
438*58b9f456SAndroid Build Coastguard Workerusing ::lrint;
439*58b9f456SAndroid Build Coastguard Workerusing ::lrintf;
440*58b9f456SAndroid Build Coastguard Workerusing ::lround;
441*58b9f456SAndroid Build Coastguard Workerusing ::lroundf;
442*58b9f456SAndroid Build Coastguard Worker
443*58b9f456SAndroid Build Coastguard Workerusing ::nan;
444*58b9f456SAndroid Build Coastguard Workerusing ::nanf;
445*58b9f456SAndroid Build Coastguard Worker
446*58b9f456SAndroid Build Coastguard Workerusing ::nearbyint;
447*58b9f456SAndroid Build Coastguard Workerusing ::nearbyintf;
448*58b9f456SAndroid Build Coastguard Workerusing ::nextafter;
449*58b9f456SAndroid Build Coastguard Workerusing ::nextafterf;
450*58b9f456SAndroid Build Coastguard Workerusing ::nexttoward;
451*58b9f456SAndroid Build Coastguard Workerusing ::nexttowardf;
452*58b9f456SAndroid Build Coastguard Workerusing ::remainder;
453*58b9f456SAndroid Build Coastguard Workerusing ::remainderf;
454*58b9f456SAndroid Build Coastguard Workerusing ::remquo;
455*58b9f456SAndroid Build Coastguard Workerusing ::remquof;
456*58b9f456SAndroid Build Coastguard Workerusing ::rint;
457*58b9f456SAndroid Build Coastguard Workerusing ::rintf;
458*58b9f456SAndroid Build Coastguard Workerusing ::round;
459*58b9f456SAndroid Build Coastguard Workerusing ::roundf;
460*58b9f456SAndroid Build Coastguard Workerusing ::scalbln;
461*58b9f456SAndroid Build Coastguard Workerusing ::scalblnf;
462*58b9f456SAndroid Build Coastguard Workerusing ::scalbn;
463*58b9f456SAndroid Build Coastguard Workerusing ::scalbnf;
464*58b9f456SAndroid Build Coastguard Workerusing ::tgamma;
465*58b9f456SAndroid Build Coastguard Workerusing ::tgammaf;
466*58b9f456SAndroid Build Coastguard Workerusing ::trunc;
467*58b9f456SAndroid Build Coastguard Workerusing ::truncf;
468*58b9f456SAndroid Build Coastguard Worker
469*58b9f456SAndroid Build Coastguard Workerusing ::acosl;
470*58b9f456SAndroid Build Coastguard Workerusing ::asinl;
471*58b9f456SAndroid Build Coastguard Workerusing ::atanl;
472*58b9f456SAndroid Build Coastguard Workerusing ::atan2l;
473*58b9f456SAndroid Build Coastguard Workerusing ::ceill;
474*58b9f456SAndroid Build Coastguard Workerusing ::cosl;
475*58b9f456SAndroid Build Coastguard Workerusing ::coshl;
476*58b9f456SAndroid Build Coastguard Workerusing ::expl;
477*58b9f456SAndroid Build Coastguard Workerusing ::fabsl;
478*58b9f456SAndroid Build Coastguard Workerusing ::floorl;
479*58b9f456SAndroid Build Coastguard Workerusing ::fmodl;
480*58b9f456SAndroid Build Coastguard Workerusing ::frexpl;
481*58b9f456SAndroid Build Coastguard Workerusing ::ldexpl;
482*58b9f456SAndroid Build Coastguard Workerusing ::logl;
483*58b9f456SAndroid Build Coastguard Workerusing ::log10l;
484*58b9f456SAndroid Build Coastguard Workerusing ::modfl;
485*58b9f456SAndroid Build Coastguard Workerusing ::powl;
486*58b9f456SAndroid Build Coastguard Workerusing ::sinl;
487*58b9f456SAndroid Build Coastguard Workerusing ::sinhl;
488*58b9f456SAndroid Build Coastguard Workerusing ::sqrtl;
489*58b9f456SAndroid Build Coastguard Workerusing ::tanl;
490*58b9f456SAndroid Build Coastguard Worker
491*58b9f456SAndroid Build Coastguard Workerusing ::tanhl;
492*58b9f456SAndroid Build Coastguard Workerusing ::acoshl;
493*58b9f456SAndroid Build Coastguard Workerusing ::asinhl;
494*58b9f456SAndroid Build Coastguard Workerusing ::atanhl;
495*58b9f456SAndroid Build Coastguard Workerusing ::cbrtl;
496*58b9f456SAndroid Build Coastguard Worker
497*58b9f456SAndroid Build Coastguard Workerusing ::copysignl;
498*58b9f456SAndroid Build Coastguard Worker
499*58b9f456SAndroid Build Coastguard Workerusing ::erfl;
500*58b9f456SAndroid Build Coastguard Workerusing ::erfcl;
501*58b9f456SAndroid Build Coastguard Workerusing ::exp2l;
502*58b9f456SAndroid Build Coastguard Workerusing ::expm1l;
503*58b9f456SAndroid Build Coastguard Workerusing ::fdiml;
504*58b9f456SAndroid Build Coastguard Workerusing ::fmal;
505*58b9f456SAndroid Build Coastguard Workerusing ::fmaxl;
506*58b9f456SAndroid Build Coastguard Workerusing ::fminl;
507*58b9f456SAndroid Build Coastguard Workerusing ::hypotl;
508*58b9f456SAndroid Build Coastguard Workerusing ::ilogbl;
509*58b9f456SAndroid Build Coastguard Workerusing ::lgammal;
510*58b9f456SAndroid Build Coastguard Workerusing ::llrintl;
511*58b9f456SAndroid Build Coastguard Workerusing ::llroundl;
512*58b9f456SAndroid Build Coastguard Workerusing ::log1pl;
513*58b9f456SAndroid Build Coastguard Workerusing ::log2l;
514*58b9f456SAndroid Build Coastguard Workerusing ::logbl;
515*58b9f456SAndroid Build Coastguard Workerusing ::lrintl;
516*58b9f456SAndroid Build Coastguard Workerusing ::lroundl;
517*58b9f456SAndroid Build Coastguard Workerusing ::nanl;
518*58b9f456SAndroid Build Coastguard Workerusing ::nearbyintl;
519*58b9f456SAndroid Build Coastguard Workerusing ::nextafterl;
520*58b9f456SAndroid Build Coastguard Workerusing ::nexttowardl;
521*58b9f456SAndroid Build Coastguard Workerusing ::remainderl;
522*58b9f456SAndroid Build Coastguard Workerusing ::remquol;
523*58b9f456SAndroid Build Coastguard Workerusing ::rintl;
524*58b9f456SAndroid Build Coastguard Workerusing ::roundl;
525*58b9f456SAndroid Build Coastguard Workerusing ::scalblnl;
526*58b9f456SAndroid Build Coastguard Workerusing ::scalbnl;
527*58b9f456SAndroid Build Coastguard Workerusing ::tgammal;
528*58b9f456SAndroid Build Coastguard Workerusing ::truncl;
529*58b9f456SAndroid Build Coastguard Worker
530*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 14
531*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY float       hypot(       float x,       float y,       float z ) { return sqrt(x*x + y*y + z*z); }
532*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY double      hypot(      double x,      double y,      double z ) { return sqrt(x*x + y*y + z*z); }
533*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }
534*58b9f456SAndroid Build Coastguard Worker
535*58b9f456SAndroid Build Coastguard Workertemplate <class _A1, class _A2, class _A3>
536*58b9f456SAndroid Build Coastguard Workerinline _LIBCPP_INLINE_VISIBILITY
537*58b9f456SAndroid Build Coastguard Workertypename __lazy_enable_if
538*58b9f456SAndroid Build Coastguard Worker<
539*58b9f456SAndroid Build Coastguard Worker    is_arithmetic<_A1>::value &&
540*58b9f456SAndroid Build Coastguard Worker    is_arithmetic<_A2>::value &&
541*58b9f456SAndroid Build Coastguard Worker    is_arithmetic<_A3>::value,
542*58b9f456SAndroid Build Coastguard Worker    __promote<_A1, _A2, _A3>
543*58b9f456SAndroid Build Coastguard Worker>::type
544*58b9f456SAndroid Build Coastguard Workerhypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
545*58b9f456SAndroid Build Coastguard Worker{
546*58b9f456SAndroid Build Coastguard Worker    typedef typename __promote<_A1, _A2, _A3>::type __result_type;
547*58b9f456SAndroid Build Coastguard Worker    static_assert((!(is_same<_A1, __result_type>::value &&
548*58b9f456SAndroid Build Coastguard Worker                     is_same<_A2, __result_type>::value &&
549*58b9f456SAndroid Build Coastguard Worker                     is_same<_A3, __result_type>::value)), "");
550*58b9f456SAndroid Build Coastguard Worker    return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
551*58b9f456SAndroid Build Coastguard Worker}
552*58b9f456SAndroid Build Coastguard Worker#endif
553*58b9f456SAndroid Build Coastguard Worker
554*58b9f456SAndroid Build Coastguard Workertemplate <class _A1>
555*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
556*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
557*58b9f456SAndroid Build Coastguard Worker__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
558*58b9f456SAndroid Build Coastguard Worker{
559*58b9f456SAndroid Build Coastguard Worker#if __has_builtin(__builtin_isnan)
560*58b9f456SAndroid Build Coastguard Worker    return __builtin_isnan(__lcpp_x);
561*58b9f456SAndroid Build Coastguard Worker#else
562*58b9f456SAndroid Build Coastguard Worker    return isnan(__lcpp_x);
563*58b9f456SAndroid Build Coastguard Worker#endif
564*58b9f456SAndroid Build Coastguard Worker}
565*58b9f456SAndroid Build Coastguard Worker
566*58b9f456SAndroid Build Coastguard Workertemplate <class _A1>
567*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
568*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
569*58b9f456SAndroid Build Coastguard Worker__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
570*58b9f456SAndroid Build Coastguard Worker{
571*58b9f456SAndroid Build Coastguard Worker    return isnan(__lcpp_x);
572*58b9f456SAndroid Build Coastguard Worker}
573*58b9f456SAndroid Build Coastguard Worker
574*58b9f456SAndroid Build Coastguard Workertemplate <class _A1>
575*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
576*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
577*58b9f456SAndroid Build Coastguard Worker__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
578*58b9f456SAndroid Build Coastguard Worker{
579*58b9f456SAndroid Build Coastguard Worker#if __has_builtin(__builtin_isinf)
580*58b9f456SAndroid Build Coastguard Worker    return __builtin_isinf(__lcpp_x);
581*58b9f456SAndroid Build Coastguard Worker#else
582*58b9f456SAndroid Build Coastguard Worker    return isinf(__lcpp_x);
583*58b9f456SAndroid Build Coastguard Worker#endif
584*58b9f456SAndroid Build Coastguard Worker}
585*58b9f456SAndroid Build Coastguard Worker
586*58b9f456SAndroid Build Coastguard Workertemplate <class _A1>
587*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
588*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
589*58b9f456SAndroid Build Coastguard Worker__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
590*58b9f456SAndroid Build Coastguard Worker{
591*58b9f456SAndroid Build Coastguard Worker    return isinf(__lcpp_x);
592*58b9f456SAndroid Build Coastguard Worker}
593*58b9f456SAndroid Build Coastguard Worker
594*58b9f456SAndroid Build Coastguard Workertemplate <class _A1>
595*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
596*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
597*58b9f456SAndroid Build Coastguard Worker__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
598*58b9f456SAndroid Build Coastguard Worker{
599*58b9f456SAndroid Build Coastguard Worker#if __has_builtin(__builtin_isfinite)
600*58b9f456SAndroid Build Coastguard Worker    return __builtin_isfinite(__lcpp_x);
601*58b9f456SAndroid Build Coastguard Worker#else
602*58b9f456SAndroid Build Coastguard Worker    return isfinite(__lcpp_x);
603*58b9f456SAndroid Build Coastguard Worker#endif
604*58b9f456SAndroid Build Coastguard Worker}
605*58b9f456SAndroid Build Coastguard Worker
606*58b9f456SAndroid Build Coastguard Workertemplate <class _A1>
607*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
608*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
609*58b9f456SAndroid Build Coastguard Worker__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
610*58b9f456SAndroid Build Coastguard Worker{
611*58b9f456SAndroid Build Coastguard Worker    return isfinite(__lcpp_x);
612*58b9f456SAndroid Build Coastguard Worker}
613*58b9f456SAndroid Build Coastguard Worker
614*58b9f456SAndroid Build Coastguard Workertemplate <class _IntT, class _FloatT,
615*58b9f456SAndroid Build Coastguard Worker    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
616*58b9f456SAndroid Build Coastguard Worker    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
617*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
618*58b9f456SAndroid Build Coastguard Worker_LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
619*58b9f456SAndroid Build Coastguard Worker  static_assert(is_floating_point<_FloatT>::value, "must be a floating point type");
620*58b9f456SAndroid Build Coastguard Worker  static_assert(is_integral<_IntT>::value, "must be an integral type");
621*58b9f456SAndroid Build Coastguard Worker  static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
622*58b9f456SAndroid Build Coastguard Worker  static_assert(is_same<_FloatT, float>::value || is_same<_FloatT, double>::value
623*58b9f456SAndroid Build Coastguard Worker               || is_same<_FloatT,long double>::value, "unsupported floating point type");
624*58b9f456SAndroid Build Coastguard Worker  return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
625*58b9f456SAndroid Build Coastguard Worker}
626*58b9f456SAndroid Build Coastguard Worker
627*58b9f456SAndroid Build Coastguard Worker// Convert a floating point number to the specified integral type after
628*58b9f456SAndroid Build Coastguard Worker// clamping to the integral types representable range.
629*58b9f456SAndroid Build Coastguard Worker//
630*58b9f456SAndroid Build Coastguard Worker// The behavior is undefined if `__r` is NaN.
631*58b9f456SAndroid Build Coastguard Workertemplate <class _IntT, class _RealT>
632*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
633*58b9f456SAndroid Build Coastguard Worker_IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
634*58b9f456SAndroid Build Coastguard Worker  using _Lim = std::numeric_limits<_IntT>;
635*58b9f456SAndroid Build Coastguard Worker  const _IntT _MaxVal = std::__max_representable_int_for_float<_IntT, _RealT>();
636*58b9f456SAndroid Build Coastguard Worker  if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) {
637*58b9f456SAndroid Build Coastguard Worker    return _Lim::max();
638*58b9f456SAndroid Build Coastguard Worker  } else if (__r <= _Lim::lowest()) {
639*58b9f456SAndroid Build Coastguard Worker    return _Lim::min();
640*58b9f456SAndroid Build Coastguard Worker  }
641*58b9f456SAndroid Build Coastguard Worker  return static_cast<_IntT>(__r);
642*58b9f456SAndroid Build Coastguard Worker}
643*58b9f456SAndroid Build Coastguard Worker
644*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
645*58b9f456SAndroid Build Coastguard Worker
646*58b9f456SAndroid Build Coastguard Worker_LIBCPP_POP_MACROS
647*58b9f456SAndroid Build Coastguard Worker
648*58b9f456SAndroid Build Coastguard Worker#endif  // _LIBCPP_CMATH
649