libquadmath.texi 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. \input texinfo @c -*-texinfo-*-
  2. @c %**start of header
  3. @setfilename libquadmath.info
  4. @settitle GCC libquadmath
  5. @c %**end of header
  6. @copying
  7. Copyright @copyright{} 2010-2022 Free Software Foundation, Inc.
  8. @quotation
  9. Permission is granted to copy, distribute and/or modify this document
  10. under the terms of the GNU Free Documentation License, Version 1.2 or
  11. any later version published by the Free Software Foundation; with no
  12. Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
  13. and with the Back-Cover Texts as in (a) below. A copy of the
  14. license is included in the section entitled ``GNU Free Documentation
  15. License.''
  16. (a) The FSF's Back-Cover Text is: ``You have the freedom to
  17. copy and modify this GNU manual.
  18. @end quotation
  19. @end copying
  20. @ifinfo
  21. @dircategory GNU Libraries
  22. @direntry
  23. * libquadmath: (libquadmath). GCC Quad-Precision Math Library
  24. @end direntry
  25. This manual documents the GCC Quad-Precision Math Library API.
  26. Published by the Free Software Foundation
  27. 51 Franklin Street, Fifth Floor
  28. Boston, MA 02110-1301 USA
  29. @insertcopying
  30. @end ifinfo
  31. @setchapternewpage odd
  32. @titlepage
  33. @title The GCC Quad-Precision Math Library
  34. @page
  35. @vskip 0pt plus 1filll
  36. @comment For the @value{version-GCC} Version*
  37. @sp 1
  38. Published by the Free Software Foundation @*
  39. 51 Franklin Street, Fifth Floor@*
  40. Boston, MA 02110-1301, USA@*
  41. @sp 1
  42. @insertcopying
  43. @end titlepage
  44. @summarycontents
  45. @contents
  46. @page
  47. @node Top
  48. @top Introduction
  49. @cindex Introduction
  50. This manual documents the usage of libquadmath, the GCC Quad-Precision
  51. Math Library Application Programming Interface (API).
  52. @comment
  53. @comment When you add a new menu item, please keep the right hand
  54. @comment aligned to the same column. Do not use tabs. This provides
  55. @comment better formatting.
  56. @comment
  57. @menu
  58. * Typedef and constants:: Defined data types and constants
  59. * Math Library Routines:: The Libquadmath math runtime application
  60. programming interface.
  61. * I/O Library Routines:: The Libquadmath I/O runtime application
  62. programming interface.
  63. * GNU Free Documentation License::
  64. How you can copy and share this manual.
  65. * Reporting Bugs:: How to report bugs in GCC Libquadmath.
  66. @c * Index:: Index of this documentation.
  67. @end menu
  68. @c ---------------------------------------------------------------------
  69. @c Defined macros
  70. @c ---------------------------------------------------------------------
  71. @node Typedef and constants
  72. @chapter Typedef and constants
  73. The following data type has been defined via @code{typedef}.
  74. @table @asis
  75. @item @code{__complex128}: @code{__float128}-based complex number
  76. @end table
  77. The following macros are defined, which give the numeric limits of the
  78. @code{__float128} data type.
  79. @table @asis
  80. @item @code{FLT128_MAX}: largest finite number
  81. @item @code{FLT128_MIN}: smallest positive number with full precision
  82. @item @code{FLT128_EPSILON}: difference between 1 and the next larger
  83. representable number
  84. @item @code{FLT128_DENORM_MIN}: smallest positive denormalized number
  85. @item @code{FLT128_MANT_DIG}: number of digits in the mantissa (bit precision)
  86. @item @code{FLT128_MIN_EXP}: maximal negative exponent
  87. @item @code{FLT128_MAX_EXP}: maximal positive exponent
  88. @item @code{FLT128_DIG}: number of decimal digits in the mantissa
  89. @item @code{FLT128_MIN_10_EXP}: maximal negative decimal exponent
  90. @item @code{FLT128_MAX_10_EXP}: maximal positive decimal exponent
  91. @end table
  92. The following mathematical constants of type @code{__float128} are defined.
  93. @table @asis
  94. @item @code{M_Eq}: the constant e (Euler's number)
  95. @item @code{M_LOG2Eq}: binary logarithm of 2
  96. @item @code{M_LOG10Eq}: common, decimal logarithm of 2
  97. @item @code{M_LN2q}: natural logarithm of 2
  98. @item @code{M_LN10q}: natural logarithm of 10
  99. @item @code{M_PIq}: pi
  100. @item @code{M_PI_2q}: pi divided by two
  101. @item @code{M_PI_4q}: pi divided by four
  102. @item @code{M_1_PIq}: one over pi
  103. @item @code{M_2_PIq}: one over two pi
  104. @item @code{M_2_SQRTPIq}: two over square root of pi
  105. @item @code{M_SQRT2q}: square root of 2
  106. @item @code{M_SQRT1_2q}: one over square root of 2
  107. @end table
  108. @c ---------------------------------------------------------------------
  109. @c Math routines
  110. @c ---------------------------------------------------------------------
  111. @node Math Library Routines
  112. @chapter Math Library Routines
  113. The following mathematical functions are available:
  114. @table @asis
  115. @item @code{acosq}: arc cosine function
  116. @item @code{acoshq}: inverse hyperbolic cosine function
  117. @item @code{asinq}: arc sine function
  118. @item @code{asinhq}: inverse hyperbolic sine function
  119. @item @code{atanq}: arc tangent function
  120. @item @code{atanhq}: inverse hyperbolic tangent function
  121. @item @code{atan2q}: arc tangent function
  122. @item @code{cbrtq}: cube root function
  123. @item @code{ceilq}: ceiling value function
  124. @item @code{copysignq}: copy sign of a number
  125. @item @code{coshq}: hyperbolic cosine function
  126. @item @code{cosq}: cosine function
  127. @item @code{erfq}: error function
  128. @item @code{erfcq}: complementary error function
  129. @item @code{exp2q}: base 2 exponential function
  130. @item @code{expq}: exponential function
  131. @item @code{expm1q}: exponential minus 1 function
  132. @need 800
  133. @item @code{fabsq}: absolute value function
  134. @item @code{fdimq}: positive difference function
  135. @item @code{finiteq}: check finiteness of value
  136. @item @code{floorq}: floor value function
  137. @item @code{fmaq}: fused multiply and add
  138. @item @code{fmaxq}: determine maximum of two values
  139. @item @code{fminq}: determine minimum of two values
  140. @item @code{fmodq}: remainder value function
  141. @item @code{frexpq}: extract mantissa and exponent
  142. @item @code{hypotq}: Eucledian distance function
  143. @item @code{ilogbq}: get exponent of the value
  144. @item @code{isinfq}: check for infinity
  145. @item @code{isnanq}: check for not a number
  146. @item @code{issignalingq}: check for signaling not a number
  147. @item @code{j0q}: Bessel function of the first kind, first order
  148. @item @code{j1q}: Bessel function of the first kind, second order
  149. @item @code{jnq}: Bessel function of the first kind, @var{n}-th order
  150. @item @code{ldexpq}: load exponent of the value
  151. @item @code{lgammaq}: logarithmic gamma function
  152. @item @code{llrintq}: round to nearest integer value
  153. @item @code{llroundq}: round to nearest integer value away from zero
  154. @item @code{logbq}: get exponent of the value
  155. @item @code{logq}: natural logarithm function
  156. @item @code{log10q}: base 10 logarithm function
  157. @item @code{log1pq}: compute natural logarithm of the value plus one
  158. @item @code{log2q}: base 2 logarithm function
  159. @need 800
  160. @item @code{lrintq}: round to nearest integer value
  161. @item @code{lroundq}: round to nearest integer value away from zero
  162. @item @code{modfq}: decompose the floating-point number
  163. @item @code{nanq}: return quiet NaN
  164. @item @code{nearbyintq}: round to nearest integer
  165. @item @code{nextafterq}: next representable floating-point number
  166. @item @code{powq}: power function
  167. @item @code{remainderq}: remainder function
  168. @item @code{remquoq}: remainder and part of quotient
  169. @item @code{rintq}: round-to-nearest integral value
  170. @item @code{roundq}: round-to-nearest integral value, return @code{__float128}
  171. @item @code{scalblnq}: compute exponent using @code{FLT_RADIX}
  172. @item @code{scalbnq}: compute exponent using @code{FLT_RADIX}
  173. @item @code{signbitq}: return sign bit
  174. @item @code{sincosq}: calculate sine and cosine simultaneously
  175. @item @code{sinhq}: hyperbolic sine function
  176. @item @code{sinq}: sine function
  177. @item @code{sqrtq}: square root function
  178. @item @code{tanq}: tangent function
  179. @item @code{tanhq}: hyperbolic tangent function
  180. @need 800
  181. @item @code{tgammaq}: true gamma function
  182. @item @code{truncq}: round to integer, towards zero
  183. @item @code{y0q}: Bessel function of the second kind, first order
  184. @item @code{y1q}: Bessel function of the second kind, second order
  185. @item @code{ynq}: Bessel function of the second kind, @var{n}-th order
  186. @item @code{cabsq} complex absolute value function
  187. @item @code{cargq}: calculate the argument
  188. @item @code{cimagq} imaginary part of complex number
  189. @item @code{crealq}: real part of complex number
  190. @item @code{cacoshq}: complex arc hyperbolic cosine function
  191. @item @code{cacosq}: complex arc cosine function
  192. @item @code{casinhq}: complex arc hyperbolic sine function
  193. @item @code{casinq}: complex arc sine function
  194. @item @code{catanhq}: complex arc hyperbolic tangent function
  195. @item @code{catanq}: complex arc tangent function
  196. @item @code{ccosq} complex cosine function:
  197. @item @code{ccoshq}: complex hyperbolic cosine function
  198. @item @code{cexpq}: complex exponential function
  199. @need 800
  200. @item @code{cexpiq}: computes the exponential function of ``i'' times a
  201. real value
  202. @item @code{clogq}: complex natural logarithm
  203. @item @code{clog10q}: complex base 10 logarithm
  204. @item @code{conjq}: complex conjugate function
  205. @item @code{cpowq}: complex power function
  206. @item @code{cprojq}: project into Riemann Sphere
  207. @item @code{csinq}: complex sine function
  208. @item @code{csinhq}: complex hyperbolic sine function
  209. @item @code{csqrtq}: complex square root
  210. @item @code{ctanq}: complex tangent function
  211. @item @code{ctanhq}: complex hyperbolic tangent function
  212. @end table
  213. @c ---------------------------------------------------------------------
  214. @c I/O routines
  215. @c ---------------------------------------------------------------------
  216. @node I/O Library Routines
  217. @chapter I/O Library Routines
  218. @menu
  219. * @code{strtoflt128}: strtoflt128, Convert from string
  220. * @code{quadmath_snprintf}: quadmath_snprintf, Convert to string
  221. @end menu
  222. @node strtoflt128
  223. @section @code{strtoflt128} --- Convert from string
  224. The function @code{strtoflt128} converts a string into a
  225. @code{__float128} number.
  226. @table @asis
  227. @item Syntax
  228. @code{__float128 strtoflt128 (const char *s, char **sp)}
  229. @item @emph{Arguments}:
  230. @multitable @columnfractions .15 .70
  231. @item @var{s} @tab input string
  232. @item @var{sp} @tab the address of the next character in the string
  233. @end multitable
  234. The argument @var{sp} contains, if not @code{NULL}, the address of the
  235. next character following the parts of the string, which have been read.
  236. @item Example
  237. @smallexample
  238. #include <quadmath.h>
  239. int main ()
  240. @{
  241. __float128 r;
  242. r = strtoflt128 ("1.2345678", NULL);
  243. return 0;
  244. @}
  245. @end smallexample
  246. @end table
  247. @node quadmath_snprintf
  248. @section @code{quadmath_snprintf} --- Convert to string
  249. The function @code{quadmath_snprintf} converts a @code{__float128} floating-point
  250. number into a string. It is a specialized alternative to @code{snprintf}, where
  251. the format string is restricted to a single conversion specifier with @code{Q}
  252. modifier and conversion specifier @code{e}, @code{E}, @code{f}, @code{F}, @code{g},
  253. @code{G}, @code{a} or @code{A}, with no extra characters before or after the
  254. conversion specifier. The @code{%m$} or @code{*m$} style must not be used in
  255. the format.
  256. @table @asis
  257. @item Syntax
  258. @code{int quadmath_snprintf (char *s, size_t size, const char *format, ...)}
  259. @item @emph{Arguments}:
  260. @multitable @columnfractions .15 .70
  261. @item @var{s} @tab output string
  262. @item @var{size} @tab byte size of the string, including trailing NUL
  263. @item @var{format} @tab conversion specifier string
  264. @end multitable
  265. @item Note
  266. On some targets when supported by the C library hooks are installed
  267. for @code{printf} family of functions, so that @code{printf ("%Qe", 1.2Q);}
  268. etc.@: works too.
  269. @item Example
  270. @smallexample
  271. #include <quadmath.h>
  272. #include <stdlib.h>
  273. #include <stdio.h>
  274. int main ()
  275. @{
  276. __float128 r;
  277. int prec = 20;
  278. int width = 46;
  279. char buf[128];
  280. r = 2.0q;
  281. r = sqrtq (r);
  282. int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r);
  283. if ((size_t) n < sizeof buf)
  284. printf ("%s\n", buf);
  285. /* Prints: +1.41421356237309504880e+00 */
  286. quadmath_snprintf (buf, sizeof buf, "%Qa", r);
  287. if ((size_t) n < sizeof buf)
  288. printf ("%s\n", buf);
  289. /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */
  290. n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r);
  291. if (n > -1)
  292. @{
  293. char *str = malloc (n + 1);
  294. if (str)
  295. @{
  296. quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r);
  297. printf ("%s\n", str);
  298. /* Prints: +1.41421356237309504880e+00 */
  299. @}
  300. free (str);
  301. @}
  302. return 0;
  303. @}
  304. @end smallexample
  305. @end table
  306. @c ---------------------------------------------------------------------
  307. @c GNU Free Documentation License
  308. @c ---------------------------------------------------------------------
  309. @include fdl.texi
  310. @c ---------------------------------------------------------------------
  311. @c Reporting Bugs
  312. @c ---------------------------------------------------------------------
  313. @c For BUGURL
  314. @include libquadmath-vers.texi
  315. @node Reporting Bugs
  316. @chapter Reporting Bugs
  317. Bugs in the GCC Quad-Precision Math Library implementation should be
  318. reported via @value{BUGURL}.
  319. @c ---------------------------------------------------------------------
  320. @c Index
  321. @c ---------------------------------------------------------------------
  322. @c @node Index
  323. @c @unnumbered Index
  324. @c
  325. @c @printindex cp
  326. @bye