abc/src/bdd/epd/epd.c
/**Function********************************************************************

  Synopsis    [Converts an arbitrary precision double value to a string.]

  Description [Converts an arbitrary precision double value to a string.]

  SideEffects []

  SeeAlso     []

******************************************************************************/
Function
Synopsis    [Converts an arbitrary precision double value to a string.]

Description [Converts an arbitrary precision double value to a string.]




Function Synopsis [ Converts an arbitrary precision double value to a string . ] Description [ Converts an arbitrary precision double value to a string . ]
void
EpdGetString(EpDouble *epd, char *str)
{
  double        value;
  int           exponent;
  char          *pos;
  if (IsNanDouble(epd->type.value)) {
    sprintf(str, "NaN");
    return;
  } else if (IsInfDouble(epd->type.value)) {
    if (epd->type.bits.sign == 1)
      sprintf(str, "-Inf");
    else
      sprintf(str, "Inf");
    return;
  }
  assert(epd->type.bits.exponent == EPD_MAX_BIN ||
         epd->type.bits.exponent == 0);
  EpdGetValueAndDecimalExponent(epd, &value, &exponent);
  sprintf(str, "%e", value);
  pos = strstr(str, "e");
  if (exponent >= 0) {
    if (exponent < 10)
      sprintf(pos + 1, "+0%d", exponent);
    else
      sprintf(pos + 1, "+%d", exponent);
  } else {
    exponent *= -1;
    if (exponent < 10)
      sprintf(pos + 1, "-0%d", exponent);
    else
      sprintf(pos + 1, "-%d", exponent);
  }
}
void EpdGetString ( EpDouble * epd , char * str ) { double value ; int exponent ; char * pos ; if ( IsNanDouble ( epd -> type . value ) ) { sprintf ( str , " " ) ; return ; } else if ( IsInfDouble ( epd -> type . value ) ) { if ( epd -> type . bits . sign == 1 ) sprintf ( str , " " ) ; else sprintf ( str , " " ) ; return ; } assert ( epd -> type . bits . exponent == EPD_MAX_BIN || epd -> type . bits . exponent == 0 ) ; EpdGetValueAndDecimalExponent ( epd , & value , & exponent ) ; sprintf ( str , " " , value ) ; pos = strstr ( str , " " ) ; if ( exponent >= 0 ) { if ( exponent < 10 ) sprintf ( pos + 1 , " " , exponent ) ; else sprintf ( pos + 1 , " " , exponent ) ; } else { exponent *= -1 ; if ( exponent < 10 ) sprintf ( pos + 1 , " " , exponent ) ; else sprintf ( pos + 1 , " " , exponent ) ; } }
Function
Synopsis    [Converts an arbitrary precision double value to a string.]
Function Synopsis [ Converts an arbitrary precision double value to a string . ]