Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

fpgetround(3C)



decconv(3C)          COMPATIBILITY FUNCTIONS          decconv(3C)



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 con-
     sidered 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 con-
     tain 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



          Last change: C Programming Language Utilities         1





decconv(3C)          COMPATIBILITY FUNCTIONS          decconv(3C)



     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 =(eq 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).
     The   ``Floating   Point   Operations''   chapter   in   the
     Programmer's Guide: ANSI C and Programming Support Tools.





























          Last change: C Programming Language Utilities         2



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026