logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

float.h.0p (10353B)


  1. '\" et
  2. .TH float.h "0P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .EQ
  11. delim $$
  12. .EN
  13. .SH NAME
  14. float.h
  15. \(em floating types
  16. .SH SYNOPSIS
  17. .LP
  18. .nf
  19. #include <float.h>
  20. .fi
  21. .SH DESCRIPTION
  22. The functionality described on this reference page is aligned with the
  23. ISO\ C standard. Any conflict between the requirements described here and the
  24. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  25. .P
  26. The characteristics of floating types are defined in terms of a model
  27. that describes a representation of floating-point numbers and values
  28. that provide information about an implementation's floating-point
  29. arithmetic.
  30. .P
  31. The following parameters are used to define the model for each
  32. floating-point type:
  33. .IP "\fIs\fP" 6
  34. Sign (\(+-1).
  35. .IP "\fIb\fP" 6
  36. Base or radix of exponent representation (an integer >1).
  37. .IP "\fIe\fP" 6
  38. Exponent (an integer between a minimum $e_ min$ and a maximum
  39. $e_ max$).
  40. .IP "\fIp\fP" 6
  41. Precision (the number of base\-\fIb\fP digits in the significand).
  42. .IP "$f_ k$" 6
  43. Non-negative integers less than
  44. .IR b
  45. (the significand digits).
  46. .P
  47. A floating-point number
  48. .IR x
  49. is defined by the following model:
  50. .P
  51. .EQ
  52. x " " = " " sb"^" e" " " " sum from k=1 to p^ " " f_ k" " " " b"^" " "-k ,
  53. " " e_ min" " " " <= " " e " " <= " " e_ max" "
  54. .EN
  55. .P
  56. In addition to normalized floating-point numbers ($f_ 1$>0 if
  57. .IR x \(!=0),
  58. floating types may be able to contain other kinds of floating-point
  59. numbers, such as subnormal floating-point numbers (\c
  60. .IR x \(!=0,
  61. .IR e =\c
  62. $e_ min$, $f_ 1$=0) and unnormalized floating-point numbers (\c
  63. .IR x \(!=0,
  64. .IR e >\c
  65. $e_ min$, $f_ 1$=0), and values that are not floating-point
  66. numbers, such as infinities and NaNs. A
  67. .IR NaN
  68. is an encoding signifying Not-a-Number. A
  69. .IR "quiet NaN"
  70. propagates through almost every arithmetic operation without raising a
  71. floating-point exception; a
  72. .IR "signaling NaN"
  73. generally raises a floating-point exception when occurring as an
  74. arithmetic operand.
  75. .P
  76. An implementation may give zero and non-numeric values, such as
  77. infinities and NaNs, a sign, or may leave them unsigned. Wherever such
  78. values are unsigned, any requirement in POSIX.1\(hy2008 to retrieve the
  79. sign shall produce an unspecified sign and any requirement to set the
  80. sign shall be ignored.
  81. .P
  82. The accuracy of the floating-point operations (\c
  83. .BR '+' ,
  84. .BR '\-' ,
  85. .BR '*' ,
  86. .BR '/' )
  87. and of the functions in
  88. .IR <math.h>
  89. and
  90. .IR <complex.h>
  91. that return floating-point results is implementation-defined, as is the
  92. accuracy of the conversion between floating-point internal
  93. representations and string representations performed by the functions
  94. in
  95. .IR <stdio.h> ,
  96. .IR <stdlib.h> ,
  97. and
  98. .IR <wchar.h> .
  99. The implementation may state that the accuracy is unknown.
  100. .P
  101. All integer values in the
  102. .IR <float.h>
  103. header, except FLT_ROUNDS, shall be constant expressions suitable for
  104. use in
  105. .BR #if
  106. preprocessing directives; all floating values shall be constant
  107. expressions. All except DECIMAL_DIG, FLT_EVAL_METHOD, FLT_RADIX, and
  108. FLT_ROUNDS have separate names for all three floating-point types. The
  109. floating-point model representation is provided for all values except
  110. FLT_EVAL_METHOD and FLT_ROUNDS.
  111. .P
  112. The rounding mode for floating-point addition is characterized by the
  113. implementation-defined value of FLT_ROUNDS:
  114. .IP "\-1" 6
  115. Indeterminable.
  116. .IP "\00" 6
  117. Toward zero.
  118. .IP "\01" 6
  119. To nearest.
  120. .IP "\02" 6
  121. Toward positive infinity.
  122. .IP "\03" 6
  123. Toward negative infinity.
  124. .P
  125. All other values for FLT_ROUNDS characterize implementation-defined
  126. rounding behavior.
  127. .P
  128. The values of operations with floating operands and values subject to
  129. the usual arithmetic conversions and of floating constants are
  130. evaluated to a format whose range and precision may be greater than
  131. required by the type. The use of evaluation formats is characterized by
  132. the implementation-defined value of FLT_EVAL_METHOD:
  133. .IP "\-1" 6
  134. Indeterminable.
  135. .IP "\00" 6
  136. Evaluate all operations and constants just to the range and
  137. precision of the type.
  138. .IP "\01" 6
  139. Evaluate operations and constants of type
  140. .BR float
  141. and
  142. .BR double
  143. to the range and precision of the
  144. .BR double
  145. type; evaluate
  146. .BR "long double"
  147. operations and constants to the range and precision of the
  148. .BR "long double"
  149. type.
  150. .IP "\02" 6
  151. Evaluate all operations and constants to the range and precision of the
  152. .BR "long double"
  153. type.
  154. .P
  155. All other negative values for FLT_EVAL_METHOD characterize
  156. implementation-defined behavior.
  157. .P
  158. The
  159. .IR <float.h>
  160. header shall define the following values as constant expressions with
  161. implementation-defined values that are greater or equal in magnitude
  162. (absolute value) to those shown, with the same sign.
  163. .IP " *" 4
  164. Radix of exponent representation,
  165. .IR b .
  166. .RS 4
  167. .IP FLT_RADIX 14
  168. 2
  169. .RE
  170. .IP " *" 4
  171. Number of base-FLT_RADIX digits in the floating-point significand,
  172. .IR p .
  173. .RS 4
  174. .IP FLT_MANT_DIG 14
  175. .IP DBL_MANT_DIG 14
  176. .IP LDBL_MANT_DIG 14
  177. .RE
  178. .IP " *" 4
  179. Number of decimal digits,
  180. .IR n ,
  181. such that any floating-point number in the widest supported floating
  182. type with $p_ max$ radix
  183. .IR b
  184. digits can be rounded to a floating-point number with
  185. .IR n
  186. decimal digits and back again without change to the value.
  187. .RS 4
  188. .P
  189. .EQ
  190. lpile { p_ max" " " " log_ 10" " " " b above
  191. left ceiling " " 1 " " + " " p_ max" " " " log_ 10" " " " b right ceiling }
  192. " " " " lpile {if " " b " " is " " a " " power " " of " " 10 above otherwise}
  193. .EN
  194. .IP DECIMAL_DIG 14
  195. 10
  196. .RE
  197. .br
  198. .RE
  199. .IP " *" 4
  200. Number of decimal digits,
  201. .IR q ,
  202. such that any floating-point number with
  203. .IR q
  204. decimal digits can be rounded into a floating-point number with
  205. .IR p
  206. radix
  207. .IR b
  208. digits and back again without change to the
  209. .IR q
  210. decimal digits.
  211. .RS 4
  212. .P
  213. .EQ
  214. lpile { p " " log_ 10" " " " b above
  215. left floor " " (p " " - " " 1) " " log_ 10" " " " b " " right floor }
  216. " " " " lpile {if " " b " " is " " a " " power " " of " " 10 above otherwise}
  217. .EN
  218. .IP FLT_DIG 14
  219. 6
  220. .IP DBL_DIG 14
  221. 10
  222. .IP LDBL_DIG 14
  223. 10
  224. .RE
  225. .IP " *" 4
  226. Minimum negative integer such that FLT_RADIX raised to that power
  227. minus 1 is a normalized floating-point number, $e_ min$.
  228. .RS 4
  229. .IP FLT_MIN_EXP 14
  230. .IP DBL_MIN_EXP 14
  231. .IP LDBL_MIN_EXP 14
  232. .RE
  233. .IP " *" 4
  234. Minimum negative integer such that 10 raised to that power is in
  235. the range of normalized floating-point numbers.
  236. .RS 4
  237. .P
  238. .EQ
  239. left ceiling " " log_ 10" " " " b"^" " "{ e_ min" " " " "^" " "-1 } ^ " " right ceiling
  240. .EN
  241. .IP FLT_MIN_10_EXP 14
  242. \-37
  243. .IP DBL_MIN_10_EXP 14
  244. \-37
  245. .IP LDBL_MIN_10_EXP 14
  246. \-37
  247. .RE
  248. .IP " *" 4
  249. Maximum integer such that FLT_RADIX raised to that power
  250. minus 1 is a representable finite floating-point number, $e_ max$.
  251. .RS 4
  252. .IP FLT_MAX_EXP 14
  253. .IP DBL_MAX_EXP 14
  254. .IP LDBL_MAX_EXP 14
  255. .P
  256. Additionally, FLT_MAX_EXP shall be at least as large as FLT_MANT_DIG,
  257. DBL_MAX_EXP shall be at least as large as DBL_MANT_DIG, and LDBL_MAX_EXP
  258. shall be at least as large as LDBL_MANT_DIG; which has the effect that
  259. FLT_MAX, DBL_MAX, and LDBL_MAX are integral.
  260. .RE
  261. .IP " *" 4
  262. Maximum integer such that 10 raised to that power is in the range
  263. of representable finite floating-point numbers.
  264. .RS 4
  265. .P
  266. .EQ
  267. left floor " " log_ 10" " ( ( 1 " " - " " b"^" " "-p ) " "
  268. b"^" e" "_ max" "^ ) " " right floor
  269. .EN
  270. .IP FLT_MAX_10_EXP 14
  271. +37
  272. .IP DBL_MAX_10_EXP 14
  273. +37
  274. .IP LDBL_MAX_10_EXP 14
  275. +37
  276. .RE
  277. .P
  278. The
  279. .IR <float.h>
  280. header shall define the following values as constant expressions with
  281. implementation-defined values that are greater than or equal to those
  282. shown:
  283. .IP " *" 4
  284. Maximum representable finite floating-point number.
  285. .RS 4
  286. .P
  287. .EQ
  288. (1 " " - " " b"^" " "-p^) " " b"^" e" "_ max" "
  289. .EN
  290. .IP FLT_MAX 14
  291. 1E+37
  292. .IP DBL_MAX 14
  293. 1E+37
  294. .IP LDBL_MAX 14
  295. 1E+37
  296. .RE
  297. .P
  298. The
  299. .IR <float.h>
  300. header shall define the following values as constant expressions with
  301. implementation-defined (positive) values that are less than or equal to
  302. those shown:
  303. .IP " *" 4
  304. The difference between 1 and the least value greater than 1
  305. that is representable in the given floating-point type, $b"^" " "{1 " " - " " p}$.
  306. .RS 4
  307. .IP FLT_EPSILON 14
  308. 1E\-5
  309. .IP DBL_EPSILON 14
  310. 1E\-9
  311. .IP LDBL_EPSILON 14
  312. 1E\-9
  313. .RE
  314. .IP " *" 4
  315. Minimum normalized positive floating-point number,
  316. $b"^" " "{ e_ min" " " " "^" " "-1 }$.
  317. .RS 4
  318. .IP FLT_MIN 14
  319. 1E\-37
  320. .IP DBL_MIN 14
  321. 1E\-37
  322. .IP LDBL_MIN 14
  323. 1E\-37
  324. .RE
  325. .LP
  326. .IR "The following sections are informative."
  327. .SH "APPLICATION USAGE"
  328. None.
  329. .SH RATIONALE
  330. All known hardware floating-point formats satisfy the property that the
  331. exponent range is larger than the number of mantissa digits. The ISO\ C standard
  332. permits a floating-point format where this property is not true, such that
  333. the largest finite value would not be integral; however, it is unlikely
  334. that there will ever be hardware support for such a floating-point format,
  335. and it introduces boundary cases that portable programs should not have
  336. to be concerned with (for example, a non-integral DBL_MAX means that
  337. \fIceil\fR()
  338. would have to worry about overflow). Therefore, this standard imposes
  339. an additional requirement that the largest representable finite value
  340. is integral.
  341. .SH "FUTURE DIRECTIONS"
  342. None.
  343. .SH "SEE ALSO"
  344. .IR "\fB<complex.h>\fP",
  345. .IR "\fB<math.h>\fP",
  346. .IR "\fB<stdio.h>\fP",
  347. .IR "\fB<stdlib.h>\fP",
  348. .IR "\fB<wchar.h>\fP"
  349. .\"
  350. .SH COPYRIGHT
  351. Portions of this text are reprinted and reproduced in electronic form
  352. from IEEE Std 1003.1-2017, Standard for Information Technology
  353. -- Portable Operating System Interface (POSIX), The Open Group Base
  354. Specifications Issue 7, 2018 Edition,
  355. Copyright (C) 2018 by the Institute of
  356. Electrical and Electronics Engineers, Inc and The Open Group.
  357. In the event of any discrepancy between this version and the original IEEE and
  358. The Open Group Standard, the original IEEE and The Open Group Standard
  359. is the referee document. The original Standard can be obtained online at
  360. http://www.opengroup.org/unix/online.html .
  361. .PP
  362. Any typographical or formatting errors that appear
  363. in this page are most likely
  364. to have been introduced during the conversion of the source files to
  365. man page format. To report such errors, see
  366. https://www.kernel.org/doc/man-pages/reporting_bugs.html .