Logo Search packages:      
Sourcecode: abakus version File versions  Download package

char * HMath::format ( const HNumber n,
char  format = 'g',
int  prec = -1 
) [static]

Formats the given number as string, using specified decimal digits. Note that the returned string must be freed.

Definition at line 704 of file hmath.cpp.

References formatExp(), formatFixed(), formatGeneral(), and HNumber::isNan().

Referenced by raise().

{
  if( hn.isNan() )
  {
    char* str = (char*)malloc( 4 );
    str[0] = 'N';
    str[1] = 'a';
    str[2] = 'N';
    str[3] = '\0';
    return str;
  }

  if( format=='g' )
    return formatGeneral( hn, prec );  
  else if( format=='f' )
    return formatFixed( hn, prec );
  else if( format=='e' )
    return formatExp( hn, prec );  

  // fallback to 'g'
  return formatGeneral( hn, prec );  
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index