DECCONV(3C-SVR4) RISC/os Reference Manual DECCONV(3C-SVR4)
NAME
decconv: _s2dec, _d2dec, _dec2s, _dec2d - convert between
binary and decimal values
SYNOPSIS
#include <ieeefp.h>
void s2dec (float *x, decimal *d, int p);
void d2dec (double *x, decimal *d, int p);
void dec2s (decimal *d, float *x, int p);
void dec2d (decimal *d, double *x, int p);
DESCRIPTION
The s2dec function returns a decimal floating-point value,
given a pointer to a single-precision binary floating-point
number and a precision specification.
On input, the value of the ilen field in the decimal should
be set to tell how many decimal digits should be output in
the mantissa for rounding purposes. If the ilen field is
not in the range 1<ilen<9, a NaN is returned. If the input
binary value x is a NaN or infinity, the returned decimal d
will be a NaN or infinity with the appropriate sign. The
exponential component of the returned decimal value is
always two digits. The structure decimal is defined in the
ieeefp.h header file.
The parameter p (0<p<ilen) specifies how many of the digits
in the output decimal mantissa string are to be considered
to be to the right of the implicit decimal point. If p is
out of range, a NaN is returned.
The d2dec function works like the s2dec function except
that it takes a pointer to a double-precision value for x.
The ilen field must be in the range of 1<ilen< 17, and the
exponential component of the returned decimal will contain
three digits.
The dec2s function returns a single-precision binary
floating-point value, given a decimal value and a precision
specification.
The parameter p( 0<p<ilen) tells how many of the digits in
the mantissa string are to be considered to be to the right
of an implicit decimal point.
Because the decimal format can represent a larger range of
numbers than the binary formats, this conversion may over-
flow or underflow. Upon overflow or underflow, a signed
infinity (signed zero) is returned, and the appropriate
Printed 11/19/92 Page 1
DECCONV(3C-SVR4) RISC/os Reference Manual DECCONV(3C-SVR4)
sticky bit is set.
The mantissa and exponent strings may contain leading zero
characters. But, once all leading 0 characters are removed,
the mantissa string should have a length > 0 and < 9 .
The exponent string should have a length > 0 and < 2 .
The special case of d==0 (decimal) is detected, in which
case the trailing 0 characters in the string are not
removed.
The dec2d function is analogous to the dec2s function
except that it returns a double-precision value. After
leading 0 characters are removed, the mantissa string should
contain no more than 17 digits and the exponent string
should contain no more than three digits.
Rounding is performed according to the current rounding
mode. The default is round-to-nearest.
Calling these functions may result in the following excep-
tions: overflow, underflow, inexact result, invalid opera-
tion.
SEE ALSO
fpgetround(3C).
Page 2 Printed 11/19/92