鱼C论坛

 找回密码
 立即注册
查看: 2260|回复: 9

[已解决]新手求助

[复制链接]
发表于 2022-11-15 21:24:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
请根据圆的半径计算圆的面积。圆周率π使用math库导入,并将其不四舍五入保留4位小数(直接截取π的4位小数)。

输入格式:
请输入一个数值,可以是整数或者小数。

输出格式:
输出计算的圆面积,
第一行直接输出结果
第二行只输出两位小数

输入样例:
25
输出样例:
1963.4375000000002
1963.44
代码长度限制
16 KB
时间限制
400 ms
内存限制
64 MB
Python (pypy3)

最佳答案
2022-11-15 21:32:25
  1. >>> import math
  2. >>> math.pi
  3. 3.141592653589793
  4. >>> type(math.pi)
  5. <class 'float'>
  6. >>> str(math.pi)
  7. '3.141592653589793'
  8. >>> str(math.pi)[:5]
  9. '3.141'
  10. >>> str(math.pi)[:6]
  11. '3.1415'
  12. >>> float(str(math.pi)[:6])
  13. 3.1415
  14. >>>
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2022-11-15 21:27:25 | 显示全部楼层
import math

a=25
c=math.pi*a*a
print(c)
print('%.2f'%c)这个Π怎么保留四位小数
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-11-15 21:32:25 | 显示全部楼层    本楼为最佳答案   
  1. >>> import math
  2. >>> math.pi
  3. 3.141592653589793
  4. >>> type(math.pi)
  5. <class 'float'>
  6. >>> str(math.pi)
  7. '3.141592653589793'
  8. >>> str(math.pi)[:5]
  9. '3.141'
  10. >>> str(math.pi)[:6]
  11. '3.1415'
  12. >>> float(str(math.pi)[:6])
  13. 3.1415
  14. >>>
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-11-15 21:41:19 | 显示全部楼层
这~~是C么?  我完了,看不懂!~~~~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-11-15 22:03:49 | 显示全部楼层
两手空空儿 发表于 2022-11-15 21:41
这~~是C么?  我完了,看不懂!~~~~

python
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-11-15 22:13:50 | 显示全部楼层
呼~~~~~~~~~~我还去找了半天math.h,也没找到PI
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-11-15 22:49:16 | 显示全部楼层
两手空空儿 发表于 2022-11-15 22:13
呼~~~~~~~~~~我还去找了半天math.h,也没找到PI

C也有

  1. sh-5.1$ ls
  2. main.c
  3. sh-5.1$ cat main.c
  4. #include <stdio.h>
  5. #include <math.h>

  6. int main(void) {
  7.     printf("%f\n", M_PI);
  8.     return 0;
  9. }
  10. sh-5.1$ gcc -g -Wall -o main main.c
  11. sh-5.1$ ls
  12. main  main.c
  13. sh-5.1$ ./main
  14. 3.141593
  15. sh-5.1$
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-11-16 09:11:00 | 显示全部楼层

从哪里能看到完整的.h文件的内容啊,我从网上找的只列出了函数
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-11-16 09:26:27 | 显示全部楼层
两手空空儿 发表于 2022-11-16 09:11
从哪里能看到完整的.h文件的内容啊,我从网上找的只列出了函数
  1. sh-5.1$ cat /usr/include/math.h
  2. /* Declarations for math functions.
  3.    Copyright (C) 1991-2022 Free Software Foundation, Inc.
  4.    This file is part of the GNU C Library.

  5.    The GNU C Library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Lesser General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2.1 of the License, or (at your option) any later version.

  9.    The GNU C Library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Lesser General Public License for more details.

  13.    You should have received a copy of the GNU Lesser General Public
  14.    License along with the GNU C Library; if not, see
  15.    <https://www.gnu.org/licenses/>.  */

  16. /*
  17. *        ISO C99 Standard: 7.12 Mathematics        <math.h>
  18. */

  19. #ifndef        _MATH_H
  20. #define        _MATH_H        1

  21. #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
  22. #include <bits/libc-header-start.h>

  23. #if defined log && defined __GNUC__
  24. # warning A macro called log was already defined when <math.h> was included.
  25. # warning This will cause compilation problems.
  26. #endif

  27. __BEGIN_DECLS

  28. /* Get definitions of __intmax_t and __uintmax_t.  */
  29. #include <bits/types.h>

  30. /* Get machine-dependent vector math functions declarations.  */
  31. #include <bits/math-vector.h>

  32. /* Gather machine dependent type support.  */
  33. #include <bits/floatn.h>

  34. /* Value returned on overflow.  With IEEE 754 floating point, this is
  35.    +Infinity, otherwise the largest representable positive value.  */
  36. #if __GNUC_PREREQ (3, 3)
  37. # define HUGE_VAL (__builtin_huge_val ())
  38. #else
  39. /* This may provoke compiler warnings, and may not be rounded to
  40.    +Infinity in all IEEE 754 rounding modes, but is the best that can
  41.    be done in ISO C while remaining a constant expression.  10,000 is
  42.    greater than the maximum (decimal) exponent for all supported
  43.    floating-point formats and widths.  */
  44. # define HUGE_VAL 1e10000
  45. #endif
  46. #ifdef __USE_ISOC99
  47. # if __GNUC_PREREQ (3, 3)
  48. #  define HUGE_VALF (__builtin_huge_valf ())
  49. #  define HUGE_VALL (__builtin_huge_vall ())
  50. # else
  51. #  define HUGE_VALF 1e10000f
  52. #  define HUGE_VALL 1e10000L
  53. # endif
  54. #endif
  55. #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
  56. # define HUGE_VAL_F16 (__builtin_huge_valf16 ())
  57. #endif
  58. #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
  59. # define HUGE_VAL_F32 (__builtin_huge_valf32 ())
  60. #endif
  61. #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
  62. # define HUGE_VAL_F64 (__builtin_huge_valf64 ())
  63. #endif
  64. #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
  65. # define HUGE_VAL_F128 (__builtin_huge_valf128 ())
  66. #endif
  67. #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
  68. # define HUGE_VAL_F32X (__builtin_huge_valf32x ())
  69. #endif
  70. #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
  71. # define HUGE_VAL_F64X (__builtin_huge_valf64x ())
  72. #endif
  73. #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
  74. # define HUGE_VAL_F128X (__builtin_huge_valf128x ())
  75. #endif

  76. #ifdef __USE_ISOC99
  77. /* IEEE positive infinity.  */
  78. # if __GNUC_PREREQ (3, 3)
  79. #  define INFINITY (__builtin_inff ())
  80. # else
  81. #  define INFINITY HUGE_VALF
  82. # endif

  83. /* IEEE Not A Number.  */
  84. # if __GNUC_PREREQ (3, 3)
  85. #  define NAN (__builtin_nanf (""))
  86. # else
  87. /* This will raise an "invalid" exception outside static initializers,
  88.    but is the best that can be done in ISO C while remaining a
  89.    constant expression.  */
  90. #  define NAN (0.0f / 0.0f)
  91. # endif
  92. #endif /* __USE_ISOC99 */

  93. #if __GLIBC_USE (IEC_60559_BFP_EXT)
  94. /* Signaling NaN macros, if supported.  */
  95. # if __GNUC_PREREQ (3, 3)
  96. #  define SNANF (__builtin_nansf (""))
  97. #  define SNAN (__builtin_nans (""))
  98. #  define SNANL (__builtin_nansl (""))
  99. # endif
  100. #endif
  101. #if (__HAVE_FLOAT16                                        \
  102.      && __GLIBC_USE (IEC_60559_TYPES_EXT)                \
  103.      && (defined __USE_GNU || !__GLIBC_USE (ISOC2X)))
  104. # define SNANF16 (__builtin_nansf16 (""))
  105. #endif
  106. #if (__HAVE_FLOAT32                                        \
  107.      && __GLIBC_USE (IEC_60559_TYPES_EXT)                \
  108.      && (defined __USE_GNU || !__GLIBC_USE (ISOC2X)))
  109. # define SNANF32 (__builtin_nansf32 (""))
  110. #endif
  111. #if (__HAVE_FLOAT64                                        \
  112.      && __GLIBC_USE (IEC_60559_TYPES_EXT)                \
  113.      && (defined __USE_GNU || !__GLIBC_USE (ISOC2X)))
  114. # define SNANF64 (__builtin_nansf64 (""))
  115. #endif
  116. #if (__HAVE_FLOAT128                                        \
  117.      && __GLIBC_USE (IEC_60559_TYPES_EXT)                \
  118.      && (defined __USE_GNU || !__GLIBC_USE (ISOC2X)))
  119. # define SNANF128 (__builtin_nansf128 (""))
  120. #endif
  121. #if (__HAVE_FLOAT32X                                        \
  122.      && __GLIBC_USE (IEC_60559_TYPES_EXT)                \
  123.      && (defined __USE_GNU || !__GLIBC_USE (ISOC2X)))
  124. # define SNANF32X (__builtin_nansf32x (""))
  125. #endif
  126. #if (__HAVE_FLOAT64X                                        \
  127.      && __GLIBC_USE (IEC_60559_TYPES_EXT)                \
  128.      && (defined __USE_GNU || !__GLIBC_USE (ISOC2X)))
  129. # define SNANF64X (__builtin_nansf64x (""))
  130. #endif
  131. #if (__HAVE_FLOAT128X                                        \
  132.      && __GLIBC_USE (IEC_60559_TYPES_EXT)                \
  133.      && (defined __USE_GNU || !__GLIBC_USE (ISOC2X)))
  134. # define SNANF128X (__builtin_nansf128x (""))
  135. #endif

  136. /* Get __GLIBC_FLT_EVAL_METHOD.  */
  137. #include <bits/flt-eval-method.h>

  138. #ifdef __USE_ISOC99
  139. /* Define the following typedefs.

  140.     float_t        floating-point type at least as wide as `float' used
  141.                 to evaluate `float' expressions
  142.     double_t        floating-point type at least as wide as `double' used
  143.                 to evaluate `double' expressions
  144. */
  145. # if __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16
  146. typedef float float_t;
  147. typedef double double_t;
  148. # elif __GLIBC_FLT_EVAL_METHOD == 1
  149. typedef double float_t;
  150. typedef double double_t;
  151. # elif __GLIBC_FLT_EVAL_METHOD == 2
  152. typedef long double float_t;
  153. typedef long double double_t;
  154. # elif __GLIBC_FLT_EVAL_METHOD == 32
  155. typedef _Float32 float_t;
  156. typedef double double_t;
  157. # elif __GLIBC_FLT_EVAL_METHOD == 33
  158. typedef _Float32x float_t;
  159. typedef _Float32x double_t;
  160. # elif __GLIBC_FLT_EVAL_METHOD == 64
  161. typedef _Float64 float_t;
  162. typedef _Float64 double_t;
  163. # elif __GLIBC_FLT_EVAL_METHOD == 65
  164. typedef _Float64x float_t;
  165. typedef _Float64x double_t;
  166. # elif __GLIBC_FLT_EVAL_METHOD == 128
  167. typedef _Float128 float_t;
  168. typedef _Float128 double_t;
  169. # elif __GLIBC_FLT_EVAL_METHOD == 129
  170. typedef _Float128x float_t;
  171. typedef _Float128x double_t;
  172. # else
  173. #  error "Unknown __GLIBC_FLT_EVAL_METHOD"
  174. # endif
  175. #endif

  176. /* Define macros for the return values of ilogb and llogb, based on
  177.    __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN.

  178.     FP_ILOGB0        Expands to a value returned by `ilogb (0.0)'.
  179.     FP_ILOGBNAN        Expands to a value returned by `ilogb (NAN)'.
  180.     FP_LLOGB0        Expands to a value returned by `llogb (0.0)'.
  181.     FP_LLOGBNAN        Expands to a value returned by `llogb (NAN)'.

  182. */

  183. #include <bits/fp-logb.h>
  184. #ifdef __USE_ISOC99
  185. # if __FP_LOGB0_IS_MIN
  186. #  define FP_ILOGB0        (-2147483647 - 1)
  187. # else
  188. #  define FP_ILOGB0        (-2147483647)
  189. # endif
  190. # if __FP_LOGBNAN_IS_MIN
  191. #  define FP_ILOGBNAN        (-2147483647 - 1)
  192. # else
  193. #  define FP_ILOGBNAN        2147483647
  194. # endif
  195. #endif
  196. #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
  197. # if __WORDSIZE == 32
  198. #  define __FP_LONG_MAX 0x7fffffffL
  199. # else
  200. #  define __FP_LONG_MAX 0x7fffffffffffffffL
  201. # endif
  202. # if __FP_LOGB0_IS_MIN
  203. #  define FP_LLOGB0        (-__FP_LONG_MAX - 1)
  204. # else
  205. #  define FP_LLOGB0        (-__FP_LONG_MAX)
  206. # endif
  207. # if __FP_LOGBNAN_IS_MIN
  208. #  define FP_LLOGBNAN        (-__FP_LONG_MAX - 1)
  209. # else
  210. #  define FP_LLOGBNAN        __FP_LONG_MAX
  211. # endif
  212. #endif

  213. /* Get the architecture specific values describing the floating-point
  214.    evaluation.  The following symbols will get defined:

  215.     FP_FAST_FMA
  216.     FP_FAST_FMAF
  217.     FP_FAST_FMAL
  218.                 If defined it indicates that the `fma' function
  219.                 generally executes about as fast as a multiply and an add.
  220.                 This macro is defined only iff the `fma' function is
  221.                 implemented directly with a hardware multiply-add instructions.
  222. */

  223. #include <bits/fp-fast.h>

  224. #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
  225. /* Rounding direction macros for fromfp functions.  */
  226. enum
  227.   {
  228.     FP_INT_UPWARD =
  229. # define FP_INT_UPWARD 0
  230.       FP_INT_UPWARD,
  231.     FP_INT_DOWNWARD =
  232. # define FP_INT_DOWNWARD 1
  233.       FP_INT_DOWNWARD,
  234.     FP_INT_TOWARDZERO =
  235. # define FP_INT_TOWARDZERO 2
  236.       FP_INT_TOWARDZERO,
  237.     FP_INT_TONEARESTFROMZERO =
  238. # define FP_INT_TONEARESTFROMZERO 3
  239.       FP_INT_TONEARESTFROMZERO,
  240.     FP_INT_TONEAREST =
  241. # define FP_INT_TONEAREST 4
  242.       FP_INT_TONEAREST,
  243.   };
  244. #endif

  245. /* The file <bits/mathcalls.h> contains the prototypes for all the
  246.    actual math functions.  These macros are used for those prototypes,
  247.    so we can easily declare each function as both `name' and `__name',
  248.    and can declare the float versions `namef' and `__namef'.  */

  249. #define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function)

  250. #define __MATHCALL_VEC(function, suffix, args)         \
  251.   __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
  252.   __MATHCALL (function, suffix, args)

  253. #define __MATHDECL_VEC(type, function,suffix, args) \
  254.   __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
  255.   __MATHDECL(type, function,suffix, args)

  256. #define __MATHCALL(function,suffix, args)        \
  257.   __MATHDECL (_Mdouble_,function,suffix, args)
  258. #define __MATHDECL(type, function,suffix, args) \
  259.   __MATHDECL_1(type, function,suffix, args); \
  260.   __MATHDECL_1(type, __CONCAT(__,function),suffix, args)
  261. #define __MATHCALLX(function,suffix, args, attrib)        \
  262.   __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
  263. #define __MATHDECLX(type, function,suffix, args, attrib) \
  264.   __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
  265.   __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
  266. #define __MATHDECL_1_IMPL(type, function, suffix, args) \
  267.   extern type __MATH_PRECNAME(function,suffix) args __THROW
  268. #define __MATHDECL_1(type, function, suffix, args) \
  269.   __MATHDECL_1_IMPL(type, function, suffix, args)
  270. /* Ignore the alias by default.  The alias is only useful with
  271.    redirections.  */
  272. #define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
  273.   __MATHDECL_1(type, function, suffix, args)

  274. #define __MATHREDIR(type, function, suffix, args, to) \
  275.   extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to)

  276. #define _Mdouble_                double
  277. #define __MATH_PRECNAME(name,r)        __CONCAT(name,r)
  278. #define __MATH_DECLARING_DOUBLE  1
  279. #define __MATH_DECLARING_FLOATN  0
  280. #include <bits/mathcalls-helper-functions.h>
  281. #include <bits/mathcalls.h>
  282. #undef        _Mdouble_
  283. #undef        __MATH_PRECNAME
  284. #undef __MATH_DECLARING_DOUBLE
  285. #undef __MATH_DECLARING_FLOATN

  286. #ifdef __USE_ISOC99


  287. /* Include the file of declarations again, this time using `float'
  288.    instead of `double' and appending f to each function name.  */

  289. # define _Mdouble_                float
  290. # define __MATH_PRECNAME(name,r) name##f##r
  291. # define __MATH_DECLARING_DOUBLE  0
  292. # define __MATH_DECLARING_FLOATN  0
  293. # include <bits/mathcalls-helper-functions.h>
  294. # include <bits/mathcalls.h>
  295. # undef        _Mdouble_
  296. # undef        __MATH_PRECNAME
  297. # undef __MATH_DECLARING_DOUBLE
  298. # undef __MATH_DECLARING_FLOATN

  299. # if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
  300.      || defined __LDBL_COMPAT \
  301.      || defined _LIBC_TEST
  302. #  ifdef __LDBL_COMPAT

  303. #   ifdef __USE_ISOC99
  304. extern float __nldbl_nexttowardf (float __x, long double __y)
  305.                                   __THROW __attribute__ ((__const__));
  306. #    ifdef __REDIRECT_NTH
  307. extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
  308.                              __nldbl_nexttowardf)
  309.      __attribute__ ((__const__));
  310. extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
  311.                               nextafter) __attribute__ ((__const__));
  312. extern long double __REDIRECT_NTH (nexttowardl,
  313.                                    (long double __x, long double __y),
  314.                                    nextafter) __attribute__ ((__const__));
  315. #    endif
  316. #   endif

  317. #   undef __MATHDECL_1
  318. #   define __MATHDECL_1(type, function,suffix, args) \
  319.   __MATHREDIR(type, function, suffix, args, __CONCAT(function,suffix))

  320. #  elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
  321. #   ifdef __REDIRECT_NTH
  322. #    ifdef __USE_ISOC99
  323. extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
  324.                             __nexttowardf_to_ieee128)
  325.   __attribute__ ((__const__));
  326. extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
  327.                              __nexttoward_to_ieee128)
  328.   __attribute__ ((__const__));

  329. #define __dremieee128 __remainderieee128
  330. #define __gammaieee128 __lgammaieee128

  331. #    endif
  332. #   endif

  333. #   undef __MATHDECL_1
  334. #   undef __MATHDECL_ALIAS

  335. #   define __REDIRTO(function, suffix) \
  336.   __ ## function ## ieee128 ## suffix
  337. #   define __REDIRTO_ALT(function, suffix) \
  338.   __ ## function ## f128 ## suffix

  339. #   define __MATHDECL_1(type, function, suffix, args) \
  340.   __MATHREDIR (type, function, suffix, args, __REDIRTO (function, suffix))
  341. #   define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
  342.   __MATHREDIR (type, function, suffix, args, __REDIRTO_ALT (alias, suffix))
  343. #  endif

  344. /* Include the file of declarations again, this time using `long double'
  345.    instead of `double' and appending l to each function name.  */

  346. #  define _Mdouble_                long double
  347. #  define __MATH_PRECNAME(name,r) name##l##r
  348. #  define __MATH_DECLARING_DOUBLE  0
  349. #  define __MATH_DECLARING_FLOATN  0
  350. #  define __MATH_DECLARE_LDOUBLE   1
  351. #  include <bits/mathcalls-helper-functions.h>
  352. #  include <bits/mathcalls.h>

  353. #  undef _Mdouble_
  354. #  undef __MATH_PRECNAME
  355. #  undef __MATH_DECLARING_DOUBLE
  356. #  undef __MATH_DECLARING_FLOATN

  357. #  if defined __LDBL_COMPAT \
  358.       || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
  359. #   undef __REDIRTO
  360. #   undef __REDIRTO_ALT
  361. #   undef __MATHDECL_1
  362. #   undef __MATHDECL_ALIAS
  363. #   define __MATHDECL_1(type, function, suffix, args) \
  364.   __MATHDECL_1_IMPL(type, function, suffix, args)
  365. #   define __MATHDECL_ALIAS(type, function, suffix, args, alias) \
  366.   __MATHDECL_1(type, function, suffix, args)
  367. #  endif
  368. # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */

  369. #endif        /* Use ISO C99.  */

  370. /* Include the file of declarations for _FloatN and _FloatNx
  371.    types.  */

  372. #if __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)
  373. # define _Mdouble_                _Float16
  374. # define __MATH_PRECNAME(name,r) name##f16##r
  375. # define __MATH_DECLARING_DOUBLE  0
  376. # define __MATH_DECLARING_FLOATN  1
  377. # if __HAVE_DISTINCT_FLOAT16
  378. #  include <bits/mathcalls-helper-functions.h>
  379. # endif
  380. # if __GLIBC_USE (IEC_60559_TYPES_EXT)
  381. #  include <bits/mathcalls.h>
  382. # endif
  383. # undef _Mdouble_
  384. # undef __MATH_PRECNAME
  385. # undef __MATH_DECLARING_DOUBLE
  386. # undef __MATH_DECLARING_FLOATN
  387. #endif /* __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC).  */

  388. #if __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)
  389. # define _Mdouble_                _Float32
  390. # define __MATH_PRECNAME(name,r) name##f32##r
  391. # define __MATH_DECLARING_DOUBLE  0
  392. # define __MATH_DECLARING_FLOATN  1
  393. # if __HAVE_DISTINCT_FLOAT32
  394. #  include <bits/mathcalls-helper-functions.h>
  395. # endif
  396. # if __GLIBC_USE (IEC_60559_TYPES_EXT)
  397. #  include <bits/mathcalls.h>
  398. # endif
  399. # undef _Mdouble_
  400. # undef __MATH_PRECNAME
  401. # undef __MATH_DECLARING_DOUBLE
  402. # undef __MATH_DECLARING_FLOATN
  403. #endif /* __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC).  */

  404. #if __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)
  405. # define _Mdouble_                _Float64
  406. # define __MATH_PRECNAME(name,r) name##f64##r
  407. # define __MATH_DECLARING_DOUBLE  0
  408. # define __MATH_DECLARING_FLOATN  1
  409. # if __HAVE_DISTINCT_FLOAT64
  410. #  include <bits/mathcalls-helper-functions.h>
  411. # endif
  412. # if __GLIBC_USE (IEC_60559_TYPES_EXT)
  413. #  include <bits/mathcalls.h>
  414. # endif
  415. # undef _Mdouble_
  416. # undef __MATH_PRECNAME
  417. # undef __MATH_DECLARING_DOUBLE
  418. # undef __MATH_DECLARING_FLOATN
  419. #endif /* __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC).  */

  420. #if __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)
  421. # define _Mdouble_                _Float128
  422. # define __MATH_PRECNAME(name,r) name##f128##r
  423. # define __MATH_DECLARING_DOUBLE  0
  424. # define __MATH_DECLARING_FLOATN  1
  425. # if __HAVE_DISTINCT_FLOAT128
  426. #  include <bits/mathcalls-helper-functions.h>
  427. # endif
  428. # if __GLIBC_USE (IEC_60559_TYPES_EXT)
  429. #  include <bits/mathcalls.h>
  430. # endif
  431. # undef _Mdouble_
  432. # undef __MATH_PRECNAME
  433. # undef __MATH_DECLARING_DOUBLE
  434. # undef __MATH_DECLARING_FLOATN
  435. #endif /* __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !_LIBC).  */

  436. #if __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)
  437. # define _Mdouble_                _Float32x
  438. # define __MATH_PRECNAME(name,r) name##f32x##r
  439. # define __MATH_DECLARING_DOUBLE  0
  440. # define __MATH_DECLARING_FLOATN  1
  441. # if __HAVE_DISTINCT_FLOAT32X
  442. #  include <bits/mathcalls-helper-functions.h>
  443. # endif
  444. # if __GLIBC_USE (IEC_60559_TYPES_EXT)
  445. #  include <bits/mathcalls.h>
  446. # endif
  447. # undef _Mdouble_
  448. # undef __MATH_PRECNAME
  449. # undef __MATH_DECLARING_DOUBLE
  450. # undef __MATH_DECLARING_FLOATN
  451. #endif /* __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC).  */

  452. #if __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)
  453. # define _Mdouble_                _Float64x
  454. # define __MATH_PRECNAME(name,r) name##f64x##r
  455. # define __MATH_DECLARING_DOUBLE  0
  456. # define __MATH_DECLARING_FLOATN  1
  457. # if __HAVE_DISTINCT_FLOAT64X
  458. #  include <bits/mathcalls-helper-functions.h>
  459. # endif
  460. # if __GLIBC_USE (IEC_60559_TYPES_EXT)
  461. #  include <bits/mathcalls.h>
  462. # endif
  463. # undef _Mdouble_
  464. # undef __MATH_PRECNAME
  465. # undef __MATH_DECLARING_DOUBLE
  466. # undef __MATH_DECLARING_FLOATN
  467. #endif /* __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC).  */

  468. #if __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)
  469. # define _Mdouble_                _Float128x
  470. # define __MATH_PRECNAME(name,r) name##f128x##r
  471. # define __MATH_DECLARING_DOUBLE  0
  472. # define __MATH_DECLARING_FLOATN  1
  473. # if __HAVE_DISTINCT_FLOAT128X
  474. #  include <bits/mathcalls-helper-functions.h>
  475. # endif
  476. # if __GLIBC_USE (IEC_60559_TYPES_EXT)
  477. #  include <bits/mathcalls.h>
  478. # endif
  479. # undef _Mdouble_
  480. # undef __MATH_PRECNAME
  481. # undef __MATH_DECLARING_DOUBLE
  482. # undef __MATH_DECLARING_FLOATN
  483. #endif /* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC).  */

  484. #undef        __MATHDECL_1_IMPL
  485. #undef        __MATHDECL_1
  486. #undef        __MATHDECL_ALIAS
  487. #undef        __MATHDECL
  488. #undef        __MATHCALL

  489. /* Declare functions returning a narrower type.  */
  490. #define __MATHCALL_NARROW_ARGS_1 (_Marg_ __x)
  491. #define __MATHCALL_NARROW_ARGS_2 (_Marg_ __x, _Marg_ __y)
  492. #define __MATHCALL_NARROW_ARGS_3 (_Marg_ __x, _Marg_ __y, _Marg_ __z)
  493. #define __MATHCALL_NARROW_NORMAL(func, nargs)                        \
  494.   extern _Mret_ func __MATHCALL_NARROW_ARGS_ ## nargs __THROW
  495. #define __MATHCALL_NARROW_REDIR(func, redir, nargs)                        \
  496.   extern _Mret_ __REDIRECT_NTH (func, __MATHCALL_NARROW_ARGS_ ## nargs, \
  497.                                 redir)
  498. #define __MATHCALL_NARROW(func, redir, nargs)        \
  499.   __MATHCALL_NARROW_NORMAL (func, nargs)

  500. #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)

  501. # define _Mret_ float
  502. # define _Marg_ double
  503. # define __MATHCALL_NAME(name) f ## name
  504. # include <bits/mathcalls-narrow.h>
  505. # undef _Mret_
  506. # undef _Marg_
  507. # undef __MATHCALL_NAME

  508. # define _Mret_ float
  509. # define _Marg_ long double
  510. # define __MATHCALL_NAME(name) f ## name ## l
  511. # ifdef __LDBL_COMPAT
  512. #  define __MATHCALL_REDIR_NAME(name) f ## name
  513. #  define __MATHCALL_REDIR_NAME2(name) f ## name
  514. #  undef __MATHCALL_NARROW
  515. #  define __MATHCALL_NARROW(func, redir, nargs) \
  516.   __MATHCALL_NARROW_REDIR (func, redir, nargs)
  517. # elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
  518. #  define __MATHCALL_REDIR_NAME(name) __ ## f32 ## name ## ieee128
  519. #  define __MATHCALL_REDIR_NAME2(name) __ ## f32 ## name ## ieee128
  520. #  undef __MATHCALL_NARROW
  521. #  define __MATHCALL_NARROW(func, redir, nargs) \
  522.   __MATHCALL_NARROW_REDIR (func, redir, nargs)
  523. # endif
  524. # include <bits/mathcalls-narrow.h>
  525. # undef _Mret_
  526. # undef _Marg_
  527. # undef __MATHCALL_NAME
  528. # if defined __LDBL_COMPAT \
  529.      || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
  530. #  undef __MATHCALL_REDIR_NAME
  531. #  undef __MATHCALL_REDIR_NAME2
  532. #  undef __MATHCALL_NARROW
  533. #  define __MATHCALL_NARROW(func, redir, nargs) \
  534.   __MATHCALL_NARROW_NORMAL (func, nargs)
  535. # endif

  536. # define _Mret_ double
  537. # define _Marg_ long double
  538. # define __MATHCALL_NAME(name) d ## name ## l
  539. # ifdef __LDBL_COMPAT
  540. #  define __MATHCALL_REDIR_NAME(name) __nldbl_d ## name ## l
  541. #  define __MATHCALL_REDIR_NAME2(name) name
  542. #  undef __MATHCALL_NARROW
  543. #  define __MATHCALL_NARROW(func, redir, nargs) \
  544.   __MATHCALL_NARROW_REDIR (func, redir, nargs)
  545. # elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
  546. #  define __MATHCALL_REDIR_NAME(name) __ ## f64 ## name ## ieee128
  547. #  define __MATHCALL_REDIR_NAME2(name) __ ## f64 ## name ## ieee128
  548. #  undef __MATHCALL_NARROW
  549. #  define __MATHCALL_NARROW(func, redir, nargs) \
  550.   __MATHCALL_NARROW_REDIR (func, redir, nargs)
  551. # endif
  552. # include <bits/mathcalls-narrow.h>
  553. # undef _Mret_
  554. # undef _Marg_
  555. # undef __MATHCALL_NAME
  556. # if defined __LDBL_COMPAT \
  557.      || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
  558. #  undef __MATHCALL_REDIR_NAME
  559. #  undef __MATHCALL_REDIR_NAME2
  560. #  undef __MATHCALL_NARROW
  561. #  define __MATHCALL_NARROW(func, redir, nargs) \
  562.   __MATHCALL_NARROW_NORMAL (func, nargs)
  563. # endif

  564. #endif

  565. #if __GLIBC_USE (IEC_60559_TYPES_EXT)

  566. # if __HAVE_FLOAT16 && __HAVE_FLOAT32
  567. #  define _Mret_ _Float16
  568. #  define _Marg_ _Float32
  569. #  define __MATHCALL_NAME(name) f16 ## name ## f32
  570. #  include <bits/mathcalls-narrow.h>
  571. #  undef _Mret_
  572. #  undef _Marg_
  573. #  undef __MATHCALL_NAME
  574. # endif

  575. # if __HAVE_FLOAT16 && __HAVE_FLOAT32X
  576. #  define _Mret_ _Float16
  577. #  define _Marg_ _Float32x
  578. #  define __MATHCALL_NAME(name) f16 ## name ## f32x
  579. #  include <bits/mathcalls-narrow.h>
  580. #  undef _Mret_
  581. #  undef _Marg_
  582. #  undef __MATHCALL_NAME
  583. # endif

  584. # if __HAVE_FLOAT16 && __HAVE_FLOAT64
  585. #  define _Mret_ _Float16
  586. #  define _Marg_ _Float64
  587. #  define __MATHCALL_NAME(name) f16 ## name ## f64
  588. #  include <bits/mathcalls-narrow.h>
  589. #  undef _Mret_
  590. #  undef _Marg_
  591. #  undef __MATHCALL_NAME
  592. # endif

  593. # if __HAVE_FLOAT16 && __HAVE_FLOAT64X
  594. #  define _Mret_ _Float16
  595. #  define _Marg_ _Float64x
  596. #  define __MATHCALL_NAME(name) f16 ## name ## f64x
  597. #  include <bits/mathcalls-narrow.h>
  598. #  undef _Mret_
  599. #  undef _Marg_
  600. #  undef __MATHCALL_NAME
  601. # endif

  602. # if __HAVE_FLOAT16 && __HAVE_FLOAT128
  603. #  define _Mret_ _Float16
  604. #  define _Marg_ _Float128
  605. #  define __MATHCALL_NAME(name) f16 ## name ## f128
  606. #  include <bits/mathcalls-narrow.h>
  607. #  undef _Mret_
  608. #  undef _Marg_
  609. #  undef __MATHCALL_NAME
  610. # endif

  611. # if __HAVE_FLOAT16 && __HAVE_FLOAT128X
  612. #  define _Mret_ _Float16
  613. #  define _Marg_ _Float128x
  614. #  define __MATHCALL_NAME(name) f16 ## name ## f128x
  615. #  include <bits/mathcalls-narrow.h>
  616. #  undef _Mret_
  617. #  undef _Marg_
  618. #  undef __MATHCALL_NAME
  619. # endif

  620. # if __HAVE_FLOAT32 && __HAVE_FLOAT32X
  621. #  define _Mret_ _Float32
  622. #  define _Marg_ _Float32x
  623. #  define __MATHCALL_NAME(name) f32 ## name ## f32x
  624. #  include <bits/mathcalls-narrow.h>
  625. #  undef _Mret_
  626. #  undef _Marg_
  627. #  undef __MATHCALL_NAME
  628. # endif

  629. # if __HAVE_FLOAT32 && __HAVE_FLOAT64
  630. #  define _Mret_ _Float32
  631. #  define _Marg_ _Float64
  632. #  define __MATHCALL_NAME(name) f32 ## name ## f64
  633. #  include <bits/mathcalls-narrow.h>
  634. #  undef _Mret_
  635. #  undef _Marg_
  636. #  undef __MATHCALL_NAME
  637. # endif

  638. # if __HAVE_FLOAT32 && __HAVE_FLOAT64X
  639. #  define _Mret_ _Float32
  640. #  define _Marg_ _Float64x
  641. #  define __MATHCALL_NAME(name) f32 ## name ## f64x
  642. #  include <bits/mathcalls-narrow.h>
  643. #  undef _Mret_
  644. #  undef _Marg_
  645. #  undef __MATHCALL_NAME
  646. # endif

  647. # if __HAVE_FLOAT32 && __HAVE_FLOAT128
  648. #  define _Mret_ _Float32
  649. #  define _Marg_ _Float128
  650. #  define __MATHCALL_NAME(name) f32 ## name ## f128
  651. #  include <bits/mathcalls-narrow.h>
  652. #  undef _Mret_
  653. #  undef _Marg_
  654. #  undef __MATHCALL_NAME
  655. # endif

  656. # if __HAVE_FLOAT32 && __HAVE_FLOAT128X
  657. #  define _Mret_ _Float32
  658. #  define _Marg_ _Float128x
  659. #  define __MATHCALL_NAME(name) f32 ## name ## f128x
  660. #  include <bits/mathcalls-narrow.h>
  661. #  undef _Mret_
  662. #  undef _Marg_
  663. #  undef __MATHCALL_NAME
  664. # endif

  665. # if __HAVE_FLOAT32X && __HAVE_FLOAT64
  666. #  define _Mret_ _Float32x
  667. #  define _Marg_ _Float64
  668. #  define __MATHCALL_NAME(name) f32x ## name ## f64
  669. #  include <bits/mathcalls-narrow.h>
  670. #  undef _Mret_
  671. #  undef _Marg_
  672. #  undef __MATHCALL_NAME
  673. # endif

  674. # if __HAVE_FLOAT32X && __HAVE_FLOAT64X
  675. #  define _Mret_ _Float32x
  676. #  define _Marg_ _Float64x
  677. #  define __MATHCALL_NAME(name) f32x ## name ## f64x
  678. #  include <bits/mathcalls-narrow.h>
  679. #  undef _Mret_
  680. #  undef _Marg_
  681. #  undef __MATHCALL_NAME
  682. # endif

  683. # if __HAVE_FLOAT32X && __HAVE_FLOAT128
  684. #  define _Mret_ _Float32x
  685. #  define _Marg_ _Float128
  686. #  define __MATHCALL_NAME(name) f32x ## name ## f128
  687. #  include <bits/mathcalls-narrow.h>
  688. #  undef _Mret_
  689. #  undef _Marg_
  690. #  undef __MATHCALL_NAME
  691. # endif

  692. # if __HAVE_FLOAT32X && __HAVE_FLOAT128X
  693. #  define _Mret_ _Float32x
  694. #  define _Marg_ _Float128x
  695. #  define __MATHCALL_NAME(name) f32x ## name ## f128x
  696. #  include <bits/mathcalls-narrow.h>
  697. #  undef _Mret_
  698. #  undef _Marg_
  699. #  undef __MATHCALL_NAME
  700. # endif

  701. # if __HAVE_FLOAT64 && __HAVE_FLOAT64X
  702. #  define _Mret_ _Float64
  703. #  define _Marg_ _Float64x
  704. #  define __MATHCALL_NAME(name) f64 ## name ## f64x
  705. #  include <bits/mathcalls-narrow.h>
  706. #  undef _Mret_
  707. #  undef _Marg_
  708. #  undef __MATHCALL_NAME
  709. # endif

  710. # if __HAVE_FLOAT64 && __HAVE_FLOAT128
  711. #  define _Mret_ _Float64
  712. #  define _Marg_ _Float128
  713. #  define __MATHCALL_NAME(name) f64 ## name ## f128
  714. #  include <bits/mathcalls-narrow.h>
  715. #  undef _Mret_
  716. #  undef _Marg_
  717. #  undef __MATHCALL_NAME
  718. # endif

  719. # if __HAVE_FLOAT64 && __HAVE_FLOAT128X
  720. #  define _Mret_ _Float64
  721. #  define _Marg_ _Float128x
  722. #  define __MATHCALL_NAME(name) f64 ## name ## f128x
  723. #  include <bits/mathcalls-narrow.h>
  724. #  undef _Mret_
  725. #  undef _Marg_
  726. #  undef __MATHCALL_NAME
  727. # endif

  728. # if __HAVE_FLOAT64X && __HAVE_FLOAT128
  729. #  define _Mret_ _Float64x
  730. #  define _Marg_ _Float128
  731. #  define __MATHCALL_NAME(name) f64x ## name ## f128
  732. #  include <bits/mathcalls-narrow.h>
  733. #  undef _Mret_
  734. #  undef _Marg_
  735. #  undef __MATHCALL_NAME
  736. # endif

  737. # if __HAVE_FLOAT64X && __HAVE_FLOAT128X
  738. #  define _Mret_ _Float64x
  739. #  define _Marg_ _Float128x
  740. #  define __MATHCALL_NAME(name) f64x ## name ## f128x
  741. #  include <bits/mathcalls-narrow.h>
  742. #  undef _Mret_
  743. #  undef _Marg_
  744. #  undef __MATHCALL_NAME
  745. # endif

  746. # if __HAVE_FLOAT128 && __HAVE_FLOAT128X
  747. #  define _Mret_ _Float128
  748. #  define _Marg_ _Float128x
  749. #  define __MATHCALL_NAME(name) f128 ## name ## f128x
  750. #  include <bits/mathcalls-narrow.h>
  751. #  undef _Mret_
  752. #  undef _Marg_
  753. #  undef __MATHCALL_NAME
  754. # endif

  755. #endif

  756. #undef __MATHCALL_NARROW_ARGS_1
  757. #undef __MATHCALL_NARROW_ARGS_2
  758. #undef __MATHCALL_NARROW_ARGS_3
  759. #undef __MATHCALL_NARROW_NORMAL
  760. #undef __MATHCALL_NARROW_REDIR
  761. #undef __MATHCALL_NARROW

  762. #if defined __USE_MISC || defined __USE_XOPEN
  763. /* This variable is used by `gamma' and `lgamma'.  */
  764. extern int signgam;
  765. #endif

  766. #if (__HAVE_DISTINCT_FLOAT16                        \
  767.      || __HAVE_DISTINCT_FLOAT32                        \
  768.      || __HAVE_DISTINCT_FLOAT64                        \
  769.      || __HAVE_DISTINCT_FLOAT32X                \
  770.      || __HAVE_DISTINCT_FLOAT64X                \
  771.      || __HAVE_DISTINCT_FLOAT128X)
  772. # error "Unsupported _FloatN or _FloatNx types for <math.h>."
  773. #endif

  774. /* Depending on the type of TG_ARG, call an appropriately suffixed
  775.    version of FUNC with arguments (including parentheses) ARGS.
  776.    Suffixed functions may not exist for long double if it has the same
  777.    format as double, or for other types with the same format as float,
  778.    double or long double.  The behavior is undefined if the argument
  779.    does not have a real floating type.  The definition may use a
  780.    conditional expression, so all suffixed versions of FUNC must
  781.    return the same type (FUNC may include a cast if necessary rather
  782.    than being a single identifier).  */
  783. #ifdef __NO_LONG_DOUBLE_MATH
  784. # if __HAVE_DISTINCT_FLOAT128
  785. #  error "Distinct _Float128 without distinct long double not supported."
  786. # endif
  787. # define __MATH_TG(TG_ARG, FUNC, ARGS)                                        \
  788.   (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS)
  789. #elif __HAVE_DISTINCT_FLOAT128
  790. # if __HAVE_GENERIC_SELECTION
  791. #  if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32
  792. #   define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS,
  793. #  else
  794. #   define __MATH_TG_F32(FUNC, ARGS)
  795. #  endif
  796. #  if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X
  797. #   if __HAVE_FLOAT64X_LONG_DOUBLE
  798. #    define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS,
  799. #   else
  800. #    define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS,
  801. #   endif
  802. #  else
  803. #   define __MATH_TG_F64X(FUNC, ARGS)
  804. #  endif
  805. #  define __MATH_TG(TG_ARG, FUNC, ARGS)        \
  806.      _Generic ((TG_ARG),                        \
  807.                float: FUNC ## f ARGS,                \
  808.                __MATH_TG_F32 (FUNC, ARGS)        \
  809.                default: FUNC ARGS,                \
  810.                long double: FUNC ## l ARGS,        \
  811.                __MATH_TG_F64X (FUNC, ARGS)        \
  812.                _Float128: FUNC ## f128 ARGS)
  813. # else
  814. #  if __HAVE_FLOATN_NOT_TYPEDEF
  815. #   error "Non-typedef _FloatN but no _Generic."
  816. #  endif
  817. #  define __MATH_TG(TG_ARG, FUNC, ARGS)                                        \
  818.      __builtin_choose_expr                                                \
  819.      (__builtin_types_compatible_p (__typeof (TG_ARG), float),                \
  820.       FUNC ## f ARGS,                                                        \
  821.       __builtin_choose_expr                                                \
  822.       (__builtin_types_compatible_p (__typeof (TG_ARG), double),        \
  823.        FUNC ARGS,                                                        \
  824.        __builtin_choose_expr                                                \
  825.        (__builtin_types_compatible_p (__typeof (TG_ARG), long double),        \
  826.         FUNC ## l ARGS,                                                        \
  827.         FUNC ## f128 ARGS)))
  828. # endif
  829. #else
  830. # define __MATH_TG(TG_ARG, FUNC, ARGS)                \
  831.   (sizeof (TG_ARG) == sizeof (float)                \
  832.    ? FUNC ## f ARGS                                \
  833.    : sizeof (TG_ARG) == sizeof (double)                \
  834.    ? FUNC ARGS                                        \
  835.    : FUNC ## l ARGS)
  836. #endif

  837. /* ISO C99 defines some generic macros which work on any data type.  */
  838. #ifdef __USE_ISOC99

  839. /* All floating-point numbers can be put in one of these categories.  */
  840. enum
  841.   {
  842.     FP_NAN =
  843. # define FP_NAN 0
  844.       FP_NAN,
  845.     FP_INFINITE =
  846. # define FP_INFINITE 1
  847.       FP_INFINITE,
  848.     FP_ZERO =
  849. # define FP_ZERO 2
  850.       FP_ZERO,
  851.     FP_SUBNORMAL =
  852. # define FP_SUBNORMAL 3
  853.       FP_SUBNORMAL,
  854.     FP_NORMAL =
  855. # define FP_NORMAL 4
  856.       FP_NORMAL
  857.   };

  858. /* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan,
  859.    so disable builtins if this is enabled.  When fixed in a newer GCC,
  860.    the __SUPPORT_SNAN__ check may be skipped for those versions.  */

  861. /* Return number of classification appropriate for X.  */
  862. # if ((__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__)                      \
  863.       || __glibc_clang_prereq (2,8))                                              \
  864.      && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)
  865.      /* The check for __cplusplus allows the use of the builtin, even
  866.         when optimization for size is on.  This is provided for
  867.         libstdc++, only to let its configure test work when it is built
  868.         with -Os.  No further use of this definition of fpclassify is
  869.         expected in C++ mode, since libstdc++ provides its own version
  870.         of fpclassify in cmath (which undefines fpclassify).  */
  871. #  define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE,              \
  872.      FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
  873. # else
  874. #  define fpclassify(x) __MATH_TG ((x), __fpclassify, (x))
  875. # endif

  876. /* Return nonzero value if sign of X is negative.  */
  877. # if __GNUC_PREREQ (6,0) || __glibc_clang_prereq (3,3)
  878. #  define signbit(x) __builtin_signbit (x)
  879. # elif defined __cplusplus
  880.   /* In C++ mode, __MATH_TG cannot be used, because it relies on
  881.      __builtin_types_compatible_p, which is a C-only builtin.
  882.      The check for __cplusplus allows the use of the builtin instead of
  883.      __MATH_TG. This is provided for libstdc++, only to let its configure
  884.      test work. No further use of this definition of signbit is expected
  885.      in C++ mode, since libstdc++ provides its own version of signbit
  886.      in cmath (which undefines signbit). */
  887. #  define signbit(x) __builtin_signbitl (x)
  888. # elif __GNUC_PREREQ (4,0)
  889. #  define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))
  890. # else
  891. #  define signbit(x) __MATH_TG ((x), __signbit, (x))
  892. # endif

  893. /* Return nonzero value if X is not +-Inf or NaN.  */
  894. # if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
  895.      || __glibc_clang_prereq (2,8)
  896. #  define isfinite(x) __builtin_isfinite (x)
  897. # else
  898. #  define isfinite(x) __MATH_TG ((x), __finite, (x))
  899. # endif

  900. /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN.  */
  901. # if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
  902.      || __glibc_clang_prereq (2,8)
  903. #  define isnormal(x) __builtin_isnormal (x)
  904. # else
  905. #  define isnormal(x) (fpclassify (x) == FP_NORMAL)
  906. # endif

  907. /* Return nonzero value if X is a NaN.  We could use `fpclassify' but
  908.    we already have this functions `__isnan' and it is faster.  */
  909. # if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
  910.      || __glibc_clang_prereq (2,8)
  911. #  define isnan(x) __builtin_isnan (x)
  912. # else
  913. #  define isnan(x) __MATH_TG ((x), __isnan, (x))
  914. # endif

  915. /* Return nonzero value if X is positive or negative infinity.  */
  916. # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \
  917.      && !defined __SUPPORT_SNAN__ && !defined __cplusplus
  918.    /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,
  919.       use the helper function, __isinff128, with older compilers.  This is
  920.       only provided for C mode, because in C++ mode, GCC has no support
  921.       for __builtin_types_compatible_p (and when in C++ mode, this macro is
  922.       not used anyway, because libstdc++ headers undefine it).  */
  923. #  define isinf(x) \
  924.     (__builtin_types_compatible_p (__typeof (x), _Float128) \
  925.      ? __isinff128 (x) : __builtin_isinf_sign (x))
  926. # elif (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \
  927.        || __glibc_clang_prereq (3,7)
  928. #  define isinf(x) __builtin_isinf_sign (x)
  929. # else
  930. #  define isinf(x) __MATH_TG ((x), __isinf, (x))
  931. # endif

  932. /* Bitmasks for the math_errhandling macro.  */
  933. # define MATH_ERRNO        1        /* errno set by math functions.  */
  934. # define MATH_ERREXCEPT        2        /* Exceptions raised by math functions.  */

  935. /* By default all math functions support both errno and exception handling
  936.    (except for soft floating point implementations which may only support
  937.    errno handling).  If errno handling is disabled, exceptions are still
  938.    supported by GLIBC.  Set math_errhandling to 0 with -ffast-math (this is
  939.    nonconforming but it is more useful than leaving it undefined).  */
  940. # ifdef __FAST_MATH__
  941. #  define math_errhandling        0
  942. # elif defined __NO_MATH_ERRNO__
  943. #  define math_errhandling        (MATH_ERREXCEPT)
  944. # else
  945. #  define math_errhandling        (MATH_ERRNO | MATH_ERREXCEPT)
  946. # endif

  947. #endif /* Use ISO C99.  */

  948. #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
  949. # include <bits/iscanonical.h>

  950. /* Return nonzero value if X is a signaling NaN.  */
  951. # ifndef __cplusplus
  952. #  define issignaling(x) __MATH_TG ((x), __issignaling, (x))
  953. # else
  954.    /* In C++ mode, __MATH_TG cannot be used, because it relies on
  955.       __builtin_types_compatible_p, which is a C-only builtin.  On the
  956.       other hand, overloading provides the means to distinguish between
  957.       the floating-point types.  The overloading resolution will match
  958.       the correct parameter (regardless of type qualifiers (i.e.: const
  959.       and volatile)).  */
  960. extern "C++" {
  961. inline int issignaling (float __val) { return __issignalingf (__val); }
  962. inline int issignaling (double __val) { return __issignaling (__val); }
  963. inline int
  964. issignaling (long double __val)
  965. {
  966. #  ifdef __NO_LONG_DOUBLE_MATH
  967.   return __issignaling (__val);
  968. #  else
  969.   return __issignalingl (__val);
  970. #  endif
  971. }
  972. #  if __HAVE_FLOAT128_UNLIKE_LDBL
  973. /* When using an IEEE 128-bit long double, _Float128 is defined as long double
  974.    in C++.  */
  975. inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
  976. #  endif
  977. } /* extern C++ */
  978. # endif

  979. /* Return nonzero value if X is subnormal.  */
  980. # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL)

  981. /* Return nonzero value if X is zero.  */
  982. # ifndef __cplusplus
  983. #  ifdef __SUPPORT_SNAN__
  984. #   define iszero(x) (fpclassify (x) == FP_ZERO)
  985. #  else
  986. #   define iszero(x) (((__typeof (x)) (x)) == 0)
  987. #  endif
  988. # else        /* __cplusplus */
  989. extern "C++" {
  990. #  ifdef __SUPPORT_SNAN__
  991. inline int
  992. iszero (float __val)
  993. {
  994.   return __fpclassifyf (__val) == FP_ZERO;
  995. }
  996. inline int
  997. iszero (double __val)
  998. {
  999.   return __fpclassify (__val) == FP_ZERO;
  1000. }
  1001. inline int
  1002. iszero (long double __val)
  1003. {
  1004. #   ifdef __NO_LONG_DOUBLE_MATH
  1005.   return __fpclassify (__val) == FP_ZERO;
  1006. #   else
  1007.   return __fpclassifyl (__val) == FP_ZERO;
  1008. #   endif
  1009. }
  1010. #   if __HAVE_FLOAT128_UNLIKE_LDBL
  1011.   /* When using an IEEE 128-bit long double, _Float128 is defined as long double
  1012.      in C++.  */
  1013. inline int
  1014. iszero (_Float128 __val)
  1015. {
  1016.   return __fpclassifyf128 (__val) == FP_ZERO;
  1017. }
  1018. #   endif
  1019. #  else
  1020. template <class __T> inline bool
  1021. iszero (__T __val)
  1022. {
  1023.   return __val == 0;
  1024. }
  1025. #  endif
  1026. } /* extern C++ */
  1027. # endif        /* __cplusplus */
  1028. #endif /* Use IEC_60559_BFP_EXT.  */

  1029. #ifdef __USE_XOPEN
  1030. /* X/Open wants another strange constant.  */
  1031. # define MAXFLOAT        3.40282347e+38F
  1032. #endif


  1033. /* Some useful constants.  */
  1034. #if defined __USE_MISC || defined __USE_XOPEN
  1035. # define M_E                2.7182818284590452354        /* e */
  1036. # define M_LOG2E        1.4426950408889634074        /* log_2 e */
  1037. # define M_LOG10E        0.43429448190325182765        /* log_10 e */
  1038. # define M_LN2                0.69314718055994530942        /* log_e 2 */
  1039. # define M_LN10                2.30258509299404568402        /* log_e 10 */
  1040. # define M_PI                3.14159265358979323846        /* pi */
  1041. # define M_PI_2                1.57079632679489661923        /* pi/2 */
  1042. # define M_PI_4                0.78539816339744830962        /* pi/4 */
  1043. # define M_1_PI                0.31830988618379067154        /* 1/pi */
  1044. # define M_2_PI                0.63661977236758134308        /* 2/pi */
  1045. # define M_2_SQRTPI        1.12837916709551257390        /* 2/sqrt(pi) */
  1046. # define M_SQRT2        1.41421356237309504880        /* sqrt(2) */
  1047. # define M_SQRT1_2        0.70710678118654752440        /* 1/sqrt(2) */
  1048. #endif

  1049. /* GNU extension to provide float constants with similar names.  */
  1050. #ifdef __USE_GNU
  1051. # define M_Ef                2.7182818284590452354f        /* e */
  1052. # define M_LOG2Ef        1.4426950408889634074f        /* log_2 e */
  1053. # define M_LOG10Ef        0.43429448190325182765f        /* log_10 e */
  1054. # define M_LN2f                0.69314718055994530942f        /* log_e 2 */
  1055. # define M_LN10f        2.30258509299404568402f        /* log_e 10 */
  1056. # define M_PIf                3.14159265358979323846f        /* pi */
  1057. # define M_PI_2f        1.57079632679489661923f        /* pi/2 */
  1058. # define M_PI_4f        0.78539816339744830962f        /* pi/4 */
  1059. # define M_1_PIf        0.31830988618379067154f        /* 1/pi */
  1060. # define M_2_PIf        0.63661977236758134308f        /* 2/pi */
  1061. # define M_2_SQRTPIf        1.12837916709551257390f        /* 2/sqrt(pi) */
  1062. # define M_SQRT2f        1.41421356237309504880f        /* sqrt(2) */
  1063. # define M_SQRT1_2f        0.70710678118654752440f        /* 1/sqrt(2) */
  1064. #endif

  1065. /* The above constants are not adequate for computation using `long double's.
  1066.    Therefore we provide as an extension constants with similar names as a
  1067.    GNU extension.  Provide enough digits for the 128-bit IEEE quad.  */
  1068. #ifdef __USE_GNU
  1069. # define M_El                2.718281828459045235360287471352662498L /* e */
  1070. # define M_LOG2El        1.442695040888963407359924681001892137L /* log_2 e */
  1071. # define M_LOG10El        0.434294481903251827651128918916605082L /* log_10 e */
  1072. # define M_LN2l                0.693147180559945309417232121458176568L /* log_e 2 */
  1073. # define M_LN10l        2.302585092994045684017991454684364208L /* log_e 10 */
  1074. # define M_PIl                3.141592653589793238462643383279502884L /* pi */
  1075. # define M_PI_2l        1.570796326794896619231321691639751442L /* pi/2 */
  1076. # define M_PI_4l        0.785398163397448309615660845819875721L /* pi/4 */
  1077. # define M_1_PIl        0.318309886183790671537767526745028724L /* 1/pi */
  1078. # define M_2_PIl        0.636619772367581343075535053490057448L /* 2/pi */
  1079. # define M_2_SQRTPIl        1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
  1080. # define M_SQRT2l        1.414213562373095048801688724209698079L /* sqrt(2) */
  1081. # define M_SQRT1_2l        0.707106781186547524400844362104849039L /* 1/sqrt(2) */
  1082. #endif

  1083. #if __HAVE_FLOAT16 && defined __USE_GNU
  1084. # define M_Ef16                __f16 (2.718281828459045235360287471352662498) /* e */
  1085. # define M_LOG2Ef16        __f16 (1.442695040888963407359924681001892137) /* log_2 e */
  1086. # define M_LOG10Ef16        __f16 (0.434294481903251827651128918916605082) /* log_10 e */
  1087. # define M_LN2f16        __f16 (0.693147180559945309417232121458176568) /* log_e 2 */
  1088. # define M_LN10f16        __f16 (2.302585092994045684017991454684364208) /* log_e 10 */
  1089. # define M_PIf16        __f16 (3.141592653589793238462643383279502884) /* pi */
  1090. # define M_PI_2f16        __f16 (1.570796326794896619231321691639751442) /* pi/2 */
  1091. # define M_PI_4f16        __f16 (0.785398163397448309615660845819875721) /* pi/4 */
  1092. # define M_1_PIf16        __f16 (0.318309886183790671537767526745028724) /* 1/pi */
  1093. # define M_2_PIf16        __f16 (0.636619772367581343075535053490057448) /* 2/pi */
  1094. # define M_2_SQRTPIf16        __f16 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
  1095. # define M_SQRT2f16        __f16 (1.414213562373095048801688724209698079) /* sqrt(2) */
  1096. # define M_SQRT1_2f16        __f16 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
  1097. #endif

  1098. #if __HAVE_FLOAT32 && defined __USE_GNU
  1099. # define M_Ef32                __f32 (2.718281828459045235360287471352662498) /* e */
  1100. # define M_LOG2Ef32        __f32 (1.442695040888963407359924681001892137) /* log_2 e */
  1101. # define M_LOG10Ef32        __f32 (0.434294481903251827651128918916605082) /* log_10 e */
  1102. # define M_LN2f32        __f32 (0.693147180559945309417232121458176568) /* log_e 2 */
  1103. # define M_LN10f32        __f32 (2.302585092994045684017991454684364208) /* log_e 10 */
  1104. # define M_PIf32        __f32 (3.141592653589793238462643383279502884) /* pi */
  1105. # define M_PI_2f32        __f32 (1.570796326794896619231321691639751442) /* pi/2 */
  1106. # define M_PI_4f32        __f32 (0.785398163397448309615660845819875721) /* pi/4 */
  1107. # define M_1_PIf32        __f32 (0.318309886183790671537767526745028724) /* 1/pi */
  1108. # define M_2_PIf32        __f32 (0.636619772367581343075535053490057448) /* 2/pi */
  1109. # define M_2_SQRTPIf32        __f32 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
  1110. # define M_SQRT2f32        __f32 (1.414213562373095048801688724209698079) /* sqrt(2) */
  1111. # define M_SQRT1_2f32        __f32 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
  1112. #endif

  1113. #if __HAVE_FLOAT64 && defined __USE_GNU
  1114. # define M_Ef64                __f64 (2.718281828459045235360287471352662498) /* e */
  1115. # define M_LOG2Ef64        __f64 (1.442695040888963407359924681001892137) /* log_2 e */
  1116. # define M_LOG10Ef64        __f64 (0.434294481903251827651128918916605082) /* log_10 e */
  1117. # define M_LN2f64        __f64 (0.693147180559945309417232121458176568) /* log_e 2 */
  1118. # define M_LN10f64        __f64 (2.302585092994045684017991454684364208) /* log_e 10 */
  1119. # define M_PIf64        __f64 (3.141592653589793238462643383279502884) /* pi */
  1120. # define M_PI_2f64        __f64 (1.570796326794896619231321691639751442) /* pi/2 */
  1121. # define M_PI_4f64        __f64 (0.785398163397448309615660845819875721) /* pi/4 */
  1122. # define M_1_PIf64        __f64 (0.318309886183790671537767526745028724) /* 1/pi */
  1123. # define M_2_PIf64        __f64 (0.636619772367581343075535053490057448) /* 2/pi */
  1124. # define M_2_SQRTPIf64        __f64 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
  1125. # define M_SQRT2f64        __f64 (1.414213562373095048801688724209698079) /* sqrt(2) */
  1126. # define M_SQRT1_2f64        __f64 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
  1127. #endif

  1128. #if __HAVE_FLOAT128 && defined __USE_GNU
  1129. # define M_Ef128        __f128 (2.718281828459045235360287471352662498) /* e */
  1130. # define M_LOG2Ef128        __f128 (1.442695040888963407359924681001892137) /* log_2 e */
  1131. # define M_LOG10Ef128        __f128 (0.434294481903251827651128918916605082) /* log_10 e */
  1132. # define M_LN2f128        __f128 (0.693147180559945309417232121458176568) /* log_e 2 */
  1133. # define M_LN10f128        __f128 (2.302585092994045684017991454684364208) /* log_e 10 */
  1134. # define M_PIf128        __f128 (3.141592653589793238462643383279502884) /* pi */
  1135. # define M_PI_2f128        __f128 (1.570796326794896619231321691639751442) /* pi/2 */
  1136. # define M_PI_4f128        __f128 (0.785398163397448309615660845819875721) /* pi/4 */
  1137. # define M_1_PIf128        __f128 (0.318309886183790671537767526745028724) /* 1/pi */
  1138. # define M_2_PIf128        __f128 (0.636619772367581343075535053490057448) /* 2/pi */
  1139. # define M_2_SQRTPIf128        __f128 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
  1140. # define M_SQRT2f128        __f128 (1.414213562373095048801688724209698079) /* sqrt(2) */
  1141. # define M_SQRT1_2f128        __f128 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
  1142. #endif

  1143. #if __HAVE_FLOAT32X && defined __USE_GNU
  1144. # define M_Ef32x        __f32x (2.718281828459045235360287471352662498) /* e */
  1145. # define M_LOG2Ef32x        __f32x (1.442695040888963407359924681001892137) /* log_2 e */
  1146. # define M_LOG10Ef32x        __f32x (0.434294481903251827651128918916605082) /* log_10 e */
  1147. # define M_LN2f32x        __f32x (0.693147180559945309417232121458176568) /* log_e 2 */
  1148. # define M_LN10f32x        __f32x (2.302585092994045684017991454684364208) /* log_e 10 */
  1149. # define M_PIf32x        __f32x (3.141592653589793238462643383279502884) /* pi */
  1150. # define M_PI_2f32x        __f32x (1.570796326794896619231321691639751442) /* pi/2 */
  1151. # define M_PI_4f32x        __f32x (0.785398163397448309615660845819875721) /* pi/4 */
  1152. # define M_1_PIf32x        __f32x (0.318309886183790671537767526745028724) /* 1/pi */
  1153. # define M_2_PIf32x        __f32x (0.636619772367581343075535053490057448) /* 2/pi */
  1154. # define M_2_SQRTPIf32x        __f32x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
  1155. # define M_SQRT2f32x        __f32x (1.414213562373095048801688724209698079) /* sqrt(2) */
  1156. # define M_SQRT1_2f32x        __f32x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
  1157. #endif

  1158. #if __HAVE_FLOAT64X && defined __USE_GNU
  1159. # define M_Ef64x        __f64x (2.718281828459045235360287471352662498) /* e */
  1160. # define M_LOG2Ef64x        __f64x (1.442695040888963407359924681001892137) /* log_2 e */
  1161. # define M_LOG10Ef64x        __f64x (0.434294481903251827651128918916605082) /* log_10 e */
  1162. # define M_LN2f64x        __f64x (0.693147180559945309417232121458176568) /* log_e 2 */
  1163. # define M_LN10f64x        __f64x (2.302585092994045684017991454684364208) /* log_e 10 */
  1164. # define M_PIf64x        __f64x (3.141592653589793238462643383279502884) /* pi */
  1165. # define M_PI_2f64x        __f64x (1.570796326794896619231321691639751442) /* pi/2 */
  1166. # define M_PI_4f64x        __f64x (0.785398163397448309615660845819875721) /* pi/4 */
  1167. # define M_1_PIf64x        __f64x (0.318309886183790671537767526745028724) /* 1/pi */
  1168. # define M_2_PIf64x        __f64x (0.636619772367581343075535053490057448) /* 2/pi */
  1169. # define M_2_SQRTPIf64x        __f64x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */
  1170. # define M_SQRT2f64x        __f64x (1.414213562373095048801688724209698079) /* sqrt(2) */
  1171. # define M_SQRT1_2f64x        __f64x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */
  1172. #endif

  1173. #if __HAVE_FLOAT128X && defined __USE_GNU
  1174. # error "M_* values needed for _Float128x"
  1175. #endif

  1176. #ifdef __USE_ISOC99
  1177. # if __GNUC_PREREQ (3, 1)
  1178. /* ISO C99 defines some macros to compare number while taking care for
  1179.    unordered numbers.  Many FPUs provide special instructions to support
  1180.    these operations.  Generic support in GCC for these as builtins went
  1181.    in 2.97, but not all cpus added their patterns until 3.1.  Therefore
  1182.    we enable the builtins from 3.1 onwards and use a generic implementation
  1183.    othwerwise.  */
  1184. #  define isgreater(x, y)        __builtin_isgreater(x, y)
  1185. #  define isgreaterequal(x, y)        __builtin_isgreaterequal(x, y)
  1186. #  define isless(x, y)                __builtin_isless(x, y)
  1187. #  define islessequal(x, y)        __builtin_islessequal(x, y)
  1188. #  define islessgreater(x, y)        __builtin_islessgreater(x, y)
  1189. #  define isunordered(x, y)        __builtin_isunordered(x, y)
  1190. # else
  1191. #  define isgreater(x, y) \
  1192.   (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
  1193.                     !isunordered (__x, __y) && __x > __y; }))
  1194. #  define isgreaterequal(x, y) \
  1195.   (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
  1196.                     !isunordered (__x, __y) && __x >= __y; }))
  1197. #  define isless(x, y) \
  1198.   (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
  1199.                     !isunordered (__x, __y) && __x < __y; }))
  1200. #  define islessequal(x, y) \
  1201.   (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
  1202.                     !isunordered (__x, __y) && __x <= __y; }))
  1203. #  define islessgreater(x, y) \
  1204.   (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
  1205.                     !isunordered (__x, __y) && __x != __y; }))
  1206. /* isunordered must always check both operands first for signaling NaNs.  */
  1207. #  define isunordered(x, y) \
  1208.   (__extension__ ({ __typeof__ (x) __u = (x); __typeof__ (y) __v = (y); \
  1209.                     __u != __v && (__u != __u || __v != __v); }))
  1210. # endif
  1211. #endif

  1212. #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
  1213. /* An expression whose type has the widest of the evaluation formats
  1214.    of X and Y (which are of floating-point types).  */
  1215. # if __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ > 64
  1216. #  define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0L)
  1217. # elif __FLT_EVAL_METHOD__ == 1 || __FLT_EVAL_METHOD__ > 32
  1218. #  define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0)
  1219. # elif __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32
  1220. #  define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0f)
  1221. # else
  1222. #  define __MATH_EVAL_FMT2(x, y) ((x) + (y))
  1223. # endif

  1224. /* Return X == Y but raising "invalid" and setting errno if X or Y is
  1225.    a NaN.  */
  1226. # if !defined __cplusplus || (__cplusplus < 201103L && !defined __GNUC__)
  1227. #  define iseqsig(x, y) \
  1228.    __MATH_TG (__MATH_EVAL_FMT2 (x, y), __iseqsig, ((x), (y)))
  1229. # else
  1230. /* In C++ mode, __MATH_TG cannot be used, because it relies on
  1231.    __builtin_types_compatible_p, which is a C-only builtin.  Moreover,
  1232.    the comparison macros from ISO C take two floating-point arguments,
  1233.    which need not have the same type.  Choosing what underlying function
  1234.    to call requires evaluating the formats of the arguments, then
  1235.    selecting which is wider.  The macro __MATH_EVAL_FMT2 provides this
  1236.    information, however, only the type of the macro expansion is
  1237.    relevant (actually evaluating the expression would be incorrect).
  1238.    Thus, the type is used as a template parameter for __iseqsig_type,
  1239.    which calls the appropriate underlying function.  */
  1240. extern "C++" {
  1241. template<typename> struct __iseqsig_type;

  1242. template<> struct __iseqsig_type<float>
  1243. {
  1244.   static int __call (float __x, float __y) throw ()
  1245.   {
  1246.     return __iseqsigf (__x, __y);
  1247.   }
  1248. };

  1249. template<> struct __iseqsig_type<double>
  1250. {
  1251.   static int __call (double __x, double __y) throw ()
  1252.   {
  1253.     return __iseqsig (__x, __y);
  1254.   }
  1255. };

  1256. template<> struct __iseqsig_type<long double>
  1257. {
  1258.   static int __call (long double __x, long double __y) throw ()
  1259.   {
  1260. #  ifndef __NO_LONG_DOUBLE_MATH
  1261.     return __iseqsigl (__x, __y);
  1262. #  else
  1263.     return __iseqsig (__x, __y);
  1264. #  endif
  1265.   }
  1266. };

  1267. #  if __HAVE_FLOAT128_UNLIKE_LDBL
  1268.   /* When using an IEEE 128-bit long double, _Float128 is defined as long double
  1269.      in C++.  */
  1270. template<> struct __iseqsig_type<_Float128>
  1271. {
  1272.   static int __call (_Float128 __x, _Float128 __y) throw ()
  1273.   {
  1274.     return __iseqsigf128 (__x, __y);
  1275.   }
  1276. };
  1277. #  endif

  1278. template<typename _T1, typename _T2>
  1279. inline int
  1280. iseqsig (_T1 __x, _T2 __y) throw ()
  1281. {
  1282. #  if __cplusplus >= 201103L
  1283.   typedef decltype (__MATH_EVAL_FMT2 (__x, __y)) _T3;
  1284. #  else
  1285.   typedef __typeof (__MATH_EVAL_FMT2 (__x, __y)) _T3;
  1286. #  endif
  1287.   return __iseqsig_type<_T3>::__call (__x, __y);
  1288. }

  1289. } /* extern "C++" */
  1290. # endif /* __cplusplus */

  1291. #endif

  1292. __END_DECLS


  1293. #endif /* math.h  */
  1294. sh-5.1$
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-11-16 09:36:42 | 显示全部楼层
打开了一片新大陆。。。。。。。。眼花缭乱
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-19 11:23

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表