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

NAME

6       floating_to_decimal,        single_to_decimal,       double_to_decimal,
7       extended_to_decimal,  quadruple_to_decimal  -  convert   floating-point
8       value to decimal record
9

SYNOPSIS

11       #include <floatingpoint.h>
12
13       void single_to_decimal(single *px, decimal_mode *pm,
14            decimal_record *pd, fp_exception_field_type *ps);
15
16
17       void double_to_decimal(double *px, decimal_mode *pm,
18            decimal_record *pd, fp_exception_field_type *ps);
19
20
21       void extended_to_decimal(extended *px, decimal_mode *pm,
22            decimal_record *pd, fp_exception_field_type *ps);
23
24
25       void quadruple_to_decimal(quadruple *px, decimal_mode *pm,
26            decimal_record *pd, fp_exception_field_type *ps);
27
28

DESCRIPTION

30       The  floating_to_decimal  functions convert the floating-point value at
31       *px into a decimal record at *pd, observing the modes specified in  *pm
32       and  setting  exceptions  in  *ps. If there are no IEEE exceptions, *ps
33       will be zero.
34
35
36       If *px is zero, infinity, or NaN, then only pdsign and pdfpclass  are
37       set. Otherwise pdexponent and pdds are also set so that
38
39         (sig)*(pd->ds)*10**(pd->exponent)
40
41
42
43       is  a  correctly  rounded  approximation to *px, where sig is +1 or −1,
44       depending upon whether pdsign is  0 or −1. pdds has at least one  and
45       no  more  than  DECIMAL_STRING_LENGTH-1  significant digits because one
46       character is used to terminate the string with a null.
47
48
49       pdds is correctly rounded according to  the  IEEE  rounding  modes  in
50       pmrd.  *ps  has  fp_inexact  set  if  the  result was inexact, and has
51       fp_overflow set if the string result does not fit in pdds  because  of
52       the limitation DECIMAL_STRING_LENGTH.
53
54
55       If  pmdf  == floating_form, then pdds always contains pmndigits sig‐
56       nificant digits. Thus if *px == 12.34 and pmndigits == 8,  then  pdds
57       will contain 12340000 and pdexponent will contain −6.
58
59
60       If  pmdf  == fixed_form and pmndigits >= 0, then the decimal value is
61       rounded at pmndigits digits to the right of  the  decimal  point.  For
62       example,  if  *px == 12.34 and pmndigits == 1, then pdds will contain
63       123 and pdexponent will be set to −1.
64
65
66       If pmdf == fixed_form and pmndigits< 0, then  the  decimal  value  is
67       rounded  at  −pmndigits  digits  to the left of the decimal point, and
68       pdds is padded with trailing zeros up to the decimal point. For  exam‐
69       ple,  if *px == 12.34 and pmn digits == −1, then pdds will contain 10
70       and pdexponent will be set to 0.
71
72
73       When pmdf == fixed_form and the value to be converted is large  enough
74       that   the    resulting   string   would   contain   more   than  DECI‐
75       MAL_STRING_LENGTH−1 digits, then the string placed in pdds is  limited
76       to exactly DECIMAL_STRING_LENGTH-1 digits (by moving the place at which
77       the value is rounded further left if need be), pdexponent is  adjusted
78       accordingly and the overflow flag is set in *ps.
79
80
81       pd->more is not used.
82
83
84       The   econvert(3C),   fconvert(3C),   gconvert(3C),   printf(3C),   and
85       sprintf(3C) functions all use double_to_decimal().
86

ATTRIBUTES

88       See attributes(5) for descriptions of the following attributes:
89
90
91
92
93       ┌─────────────────────────────┬─────────────────────────────┐
94       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
95       ├─────────────────────────────┼─────────────────────────────┤
96       │MT-Level                     │MT-Safe                      │
97       └─────────────────────────────┴─────────────────────────────┘
98

SEE ALSO

100       econvert(3C),  fconvert(3C),  gconvert(3C),  printf(3C),   sprintf(3C),
101       attributes(5)
102
103
104
105SunOS 5.11                        7 Jun 2005           floating_to_decimal(3C)
Impressum