xref: /titanic_50/usr/src/man/man3c/decimal_to_floating.3c (revision 2777f608ce96fd0d3b91accea29d21d6aacbe7e5)
te
Copyright (c) 1996, Sun Microsystems, Inc.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
DECIMAL_TO_FLOATING 3C "Oct 1, 2001"
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
SEE ALSO

scanf(3C), string_to_decimal(3C), strtod(3C), attributes(5)