man pages section 3: Basic Library Functions

decimal_to_floating(3C)

Name

decimal_to_floating, decimal_to_single, decimal_to_double, decimal_to_extended, decimal_to_quadruple– convert decimal record to floating-point value

Synopsis

```#include <floatingpoint.h>

void decimal_to_single(single *px, decimal_mode *pm,
decimal_record *pd, fp_exception_field_type *ps);```
```void decimal_to_double(double *px, decimal_mode *pm,
decimal_record *pd, fp_exception_field_type *ps);```
```void decimal_to_extended(extended *px, decimal_mode *pm,
decimal_record *pd, fp_exception_field_type *ps);```
```void decimal_to_quadruple(quadruple *px, decimal_mode *pm,
decimal_record *pd, fp_exception_field_type *ps);```

Description

These functions convert the decimal record *pd to a floating-point value *px observing the rounding direction specified in *pm and setting *ps to reflect any floating-point exceptions that occur.

When pd->fpclass is fp_zero, fp_infinity, fp_quiet, or fp_signaling, *px is set to zero, infinity, a quiet NaN, or a signaling NaN, respectively, with the sign indicated by pd->sign. All other fields in *pd are ignored.

When pd->fpclass is fp_normal or fp_subnormal, pd->ds must contain a null-terminated string of one or more ASCII digits representing a non-zero integer m, and pd->ndigits must be equal to the length of this string. Then *px is set to a correctly rounded approximation to

`-1**(pd->sign) * m * 10**(pd->exponent)`

pd->more can be set to a non-zero value to indicate that insignificant trailing digits were omitted from pd->ds. In this case, m is replaced by m + delta in the expression above, where delta is some tiny positive fraction.

The converted value is rounded according to the rounding direction specified in pm->rd. pm->df and pm->ndigits are not used.

On exit, *ps contains a bitwise OR of flags corresponding to any floating-point exceptions that occurred. The only possible exceptions are underflow, overflow, and inexact. If no floating-point exceptions occurred, *ps is set to zero.

Attributes

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE

ATTRIBUTE VALUE

MT-Level

MT-Safe