1 // Stub definitions for float math.
3 // Copyright (C) 2001, 2002, 2003, 2009 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
32 // For targets which do not have support for float versions,
33 // we use the following crude approximations. We keep saying that we'll do
34 // better later, but never do.
38 #ifndef _GLIBCXX_HAVE_FABSF
42 return (float) fabs(x);
46 #ifndef _GLIBCXX_HAVE_ACOSF
50 return (float) acos(x);
54 #ifndef _GLIBCXX_HAVE_ASINF
58 return (float) asin(x);
62 #ifndef _GLIBCXX_HAVE_ATANF
66 return (float) atan(x);
70 #ifndef _GLIBCXX_HAVE_ATAN2F
72 atan2f(float x, float y)
74 return (float) atan2(x, y);
78 #ifndef _GLIBCXX_HAVE_CEILF
82 return (float) ceil(x);
86 #ifndef _GLIBCXX_HAVE_COSF
90 return (float) cos(x);
94 #ifndef _GLIBCXX_HAVE_COSHF
98 return (float) cosh(x);
102 #ifndef _GLIBCXX_HAVE_EXPF
106 return (float) exp(x);
110 #ifndef _GLIBCXX_HAVE_FLOORF
114 return (float) floor(x);
118 #ifndef _GLIBCXX_HAVE_FMODF
120 fmodf(float x, float y)
122 return (float) fmod(x, y);
126 #ifndef _GLIBCXX_HAVE_FREXPF
128 frexpf(float x, int *exp)
130 return (float) frexp(x, exp);
134 #ifndef _GLIBCXX_HAVE_SQRTF
138 return (float) sqrt(x);
142 #ifndef _GLIBCXX_HAVE_HYPOTF
144 hypotf(float x, float y)
146 float s = fabsf(x) + fabsf(y);
150 return s * sqrtf(x * x + y * y);
154 #ifndef _GLIBCXX_HAVE_LDEXPF
156 ldexpf(float x, int exp)
158 return (float) ldexp(x, exp);
162 #ifndef _GLIBCXX_HAVE_LOGF
166 return (float) log(x);
170 #ifndef _GLIBCXX_HAVE_LOG10F
174 return (float) log10(x);
178 #ifndef _GLIBCXX_HAVE_MODFF
180 modff(float x, float *iptr)
184 result = modf(x, &temp);
185 *iptr = (float) temp;
186 return (float) result;
190 #ifndef _GLIBCXX_HAVE_POWF
192 powf(float x, float y)
194 return (float) pow(x, y);
198 #ifndef _GLIBCXX_HAVE_SINF
202 return (float) sin(x);
206 #ifndef _GLIBCXX_HAVE_SINHF
210 return (float) sinh(x);
214 #ifndef _GLIBCXX_HAVE_TANF
218 return (float) tan(x);
222 #ifndef _GLIBCXX_HAVE_TANHF
226 return (float) tanh(x);