1econvert(3C)             Standard C Library Functions             econvert(3C)
2
3
4

NAME

6       econvert,  fconvert,  gconvert, seconvert, sfconvert, sgconvert, qecon‐
7       vert, qfconvert, qgconvert - output conversion
8

SYNOPSIS

10       #include <floatingpoint.h>
11
12       char *econvert(double value, int ndigit, int *decpt, int *sign,
13            char *buf);
14
15
16       char *fconvert(double value, int ndigit, int *decpt, int *sign,
17            char *buf);
18
19
20       char *gconvert(double value, int ndigit, int trailing, char *buf);
21
22
23       char *seconvert(single *value, int ndigit, int *decpt, int *sign,
24            char *buf);
25
26
27       char *sfconvert(single *value, int ndigit, int *decpt, int *sign,
28            char *buf);
29
30
31       char *sgconvert(single *value, int ndigit, int trailing, char *buf);
32
33
34       char *qeconvert(quadruple *value, int ndigit, int *decpt, int *sign,
35            char *buf);
36
37
38       char *qfconvert(quadruple *value, int ndigit, int *decpt, int *sign
39            char *buf);
40
41
42       char *qgconvert(quadruple *value, int ndigit, int trailing, char *buf);
43
44

DESCRIPTION

46       The econvert() function converts the value to a null-terminated  string
47       of  ndigit ASCII digits in buf and returns a pointer to buf. buf should
48       contain at least ndigit+1 characters. The position of the decimal point
49       relative  to  the  beginning of the string is stored indirectly through
50       decpt. Thus buf == "314" and *decpt == 1 corresponds to  the  numerical
51       value  3.14,  while  buf  ==  "314" and *decpt == −1 corresponds to the
52       numerical value .0314. If the sign of the result is negative, the  word
53       pointed to by sign is nonzero; otherwise it is zero. The least signifi‐
54       cant digit is rounded.
55
56
57       The fconvert() function works much like  econvert(),  except  that  the
58       correct  digit  has  been rounded as if for  sprintf(%w.nf) output with
59       n=ndigit digits to the right of the decimal point. ndigit can be  nega‐
60       tive  to indicate rounding to the left of the decimal point. The return
61       value  is  a  pointer   to   buf.   buf   should   contain   at   least
62       310+max(0,ndigit) characters to accomodate any double-precision value.
63
64
65       The  gconvert()  function converts the value to a null-terminated ASCII
66       string in buf and returns a pointer to buf. It produces ndigit signifi‐
67       cant digits in fixed-decimal format, like  sprintf(%w.nf), if possible,
68       and otherwise in  floating-decimal  format,  like   sprintf(%w.ne);  in
69       either  case  buf  is  ready  for printing, with sign and exponent. The
70       result corresponds to that obtained by
71
72         (void) sprintf(buf,``%w.ng'',value) ;
73
74
75
76       If trailing = 0, trailing zeros and a trailing point are suppressed, as
77       in   sprintf(%g). If trailing != 0, trailing zeros and a trailing point
78       are retained, as in  sprintf(%#g).
79
80
81       The seconvert(), sfconvert(), and sgconvert() functions are single-pre‐
82       cision  versions  of  these  functions, and are more efficient than the
83       corresponding double-precision versions.  A  pointer  rather  than  the
84       value  itself  is passed to avoid C's usual conversion of single-preci‐
85       sion arguments to double.
86
87
88       The qeconvert(), qfconvert(), and qgconvert() functions are  quadruple-
89       precision  versions  of  these  functions. The qfconvert() function can
90       overflow the  decimal_record field  ds if value is too large.  In  that
91       case, buf[0] is set to zero.
92
93
94       The  ecvt(),  fcvt()  and  gcvt() functions are versions of econvert(),
95       fconvert(), and gconvert(), respectively, that are  documented  on  the
96       ecvt(3C)  manual  page.   They constitute the default implementation of
97       these functions and conform to the  X/Open  CAE  Specification,  System
98       Interfaces and Headers, Issue 4, Version 2.
99

USAGE

101       IEEE  Infinities  and  NaNs  are  treated similarly by these functions.
102       ``NaN'' is returned for NaN, and ``Inf'' or ``Infinity'' for  Infinity.
103       The longer form is produced when ndigit >= 8.
104

ATTRIBUTES

106       See attributes(5) for descriptions of the following attributes:
107
108
109
110
111       ┌─────────────────────────────┬─────────────────────────────┐
112       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
113       ├─────────────────────────────┼─────────────────────────────┤
114       │MT-Level                     │MT-Safe                      │
115       └─────────────────────────────┴─────────────────────────────┘
116

SEE ALSO

118       ecvt(3C),sprintf(3C), attributes(5)
119
120
121
122SunOS 5.11                        3 May 1999                      econvert(3C)
Impressum