Debian Codegraph @

upstream/debian-unstable/man3/gcvt.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH gcvt 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 gcvt \- convert a floating-point number to a string
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <stdlib.h>
16 .P
17 .BI "char *gcvt(double " number ", int " ndigit ", char *" buf );
18 .fi
19 .P
20 .RS -4
21 Feature Test Macro Requirements for glibc (see
22 .BR feature_test_macros (7)):
23 .RE
24 .P
25 .BR gcvt ():
26 .nf
27 Since glibc 2.17
28 (_XOPEN_SOURCE >= 500 && ! (_POSIX_C_SOURCE >= 200809L))
29 || /* glibc >= 2.20 */ _DEFAULT_SOURCE
30 || /* glibc <= 2.19 */ _SVID_SOURCE
31 glibc 2.12 to glibc 2.16:
32 (_XOPEN_SOURCE >= 500 && ! (_POSIX_C_SOURCE >= 200112L))
33 || _SVID_SOURCE
34 Before glibc 2.12:
35 _SVID_SOURCE || _XOPEN_SOURCE >= 500
36 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
37 .fi
38 .SH DESCRIPTION
39 The
40 .BR gcvt ()
41 function converts
42 .I number
43 to a minimal length null-terminated ASCII string
44 and stores the result in
45 .IR buf .
46 It produces
47 .I ndigit
48 significant digits in either
49 .BR printf (3)
50 F format or E format.
51 .SH RETURN VALUE
52 The
53 .BR gcvt ()
54 function returns
55 .IR buf .
56 .SH ATTRIBUTES
57 For an explanation of the terms used in this section, see
58 .BR attributes (7).
59 .TS
60 allbox;
61 lbx lb lb
62 l l l.
63 Interface Attribute Value
64 T{
65 .na
66 .nh
67 .BR gcvt ()
68 T} Thread safety MT-Safe
69 .TE
70 .SH STANDARDS
71 None.
72 .SH HISTORY
73 Marked as LEGACY in POSIX.1-2001.
74 POSIX.1-2008 removed it,
75 recommending the use of
76 .BR sprintf (3)
77 instead (though
78 .BR snprintf (3)
79 may be preferable).
80 .SH SEE ALSO
81 .BR ecvt (3),
82 .BR fcvt (3),
83 .BR sprintf (3)