aboutsummaryrefslogtreecommitdiff
path: root/manual/arith.texi
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>2016-06-28 17:30:42 -0300
committerGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>2016-10-25 17:03:54 -0200
commit6962682ffe5e5f0373047a0b894fee7a774be254 (patch)
treee8e3660cf706a62dc9c71972aa2acf165caf5c48 /manual/arith.texi
parent78b7adbaea643f2f213bb113e3ec933416a769a8 (diff)
downloadglibc-6962682ffe5e5f0373047a0b894fee7a774be254.tar
glibc-6962682ffe5e5f0373047a0b894fee7a774be254.tar.gz
glibc-6962682ffe5e5f0373047a0b894fee7a774be254.tar.bz2
glibc-6962682ffe5e5f0373047a0b894fee7a774be254.zip
Add strfromd, strfromf, and strfroml functions
ISO/IEC TS 18661-1 adds several functions in the strfrom family to stdlib. This patch adds strfromd, strfromf, and strfroml. This is being done in preparation for the new floating-point type, float128. The added functions convert a floating-point value into a string, with configurable format.
Diffstat (limited to 'manual/arith.texi')
-rw-r--r--manual/arith.texi41
1 files changed, 41 insertions, 0 deletions
diff --git a/manual/arith.texi b/manual/arith.texi
index e53988a083..eaaf2b7127 100644
--- a/manual/arith.texi
+++ b/manual/arith.texi
@@ -20,6 +20,7 @@ These functions are declared in the header files @file{math.h} and
* Complex Numbers:: The types. Writing complex constants.
* Operations on Complex:: Projection, conjugation, decomposition.
* Parsing of Numbers:: Converting strings to numbers.
+* Printing of Floats:: Converting floating-point numbers to strings.
* System V Number Conversion:: An archaic way to convert numbers to strings.
@end menu
@@ -2806,6 +2807,46 @@ which take an additional argument, the locale to use in conversion.
See also @ref{Parsing of Integers}.
+@node Printing of Floats
+@section Printing of Floats
+
+@pindex stdlib.h
+The @samp{strfrom} functions are declared in @file{stdlib.h}.
+
+@comment stdlib.h
+@comment ISO/IEC TS 18661-1
+@deftypefun int strfromd (char *restrict @var{string}, size_t @var{size}, const char *restrict @var{format}, double @var{value})
+@deftypefunx int strfromf (char *restrict @var{string}, size_t @var{size}, const char *restrict @var{format}, float @var{value})
+@deftypefunx int strfroml (char *restrict @var{string}, size_t @var{size}, const char *restrict @var{format}, long double @var{value})
+@safety{@prelim{}@mtsafe{@mtslocale{}}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
+@comment these functions depend on __printf_fp and __printf_fphex, which are
+@comment AS-unsafe (ascuheap) and AC-unsafe (acsmem).
+The functions @code{strfromd} (``string-from-double''), @code{strfromf}
+(``string-from-float''), and @code{strfroml} (``string-from-long-double'')
+convert the floating-point number @var{value} to a string of characters and
+stores them into the area pointed to by @var{string}. The conversion
+writes at most @var{size} characters and respects the format specified by
+@var{format}.
+
+The format string must start with the character @samp{%}. An optional
+precision follows, which starts with a period, @samp{.}, and may be
+followed by a decimal integer, representing the precision. If a decimal
+integer is not specified after the period, the precision is taken to be
+zero. The character @samp{*} is not allowed. Finally, the format string
+ends with one of the following conversion specifiers: @samp{a}, @samp{A},
+@samp{e}, @samp{E}, @samp{f}, @samp{F}, @samp{g} or @samp{G} (@pxref{Table
+of Output Conversions}). Invalid format strings result in undefined
+behavior.
+
+These functions return the number of characters that would have been
+written to @var{string} had @var{size} been sufficiently large, not
+counting the terminating null character. Thus, the null-terminated output
+has been completely written if and only if the returned value is less than
+@var{size}.
+
+These functions were introduced by ISO/IEC TS 18661-1.
+@end deftypefun
+
@node System V Number Conversion
@section Old-fashioned System V number-to-string functions