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

wxString wxPdfDocument::Double2String ( double  value,
int  precision = 0 
) [static]

Formats a floating point number with a fixed precision.

Parameters:
valuethe value to be formatted
precisionthe number of decimal places
Returns:
the string representation of the number

Definition at line 2073 of file pdfdoc.cpp.

Referenced by AddPage(), Arrow(), Cell(), ClippingEllipse(), ClippingRect(), ClippingText(), DoDecoration(), DoXmlAlign(), Ellipse(), GetUniqueId(), Line(), MultiCell(), OutCurve(), OutImage(), OutIndirectObject(), OutLine(), OutLineRelative(), OutPoint(), OutPointRelative(), wxPdfImage::ParseWMF(), PutBookmarks(), PutCatalog(), PutExtGStates(), PutPages(), PutShaders(), PutSpotColors(), PutTemplates(), Rect(), RGB2String(), SelectFont(), wxPdfColour::SetColor(), SetFontSize(), SetLineStyle(), SetLineWidth(), Text(), Transform(), UseTemplate(), and wxPdfNumber::wxPdfNumber().

{
  wxString number;
  if (precision < 0)
  {
    precision = 0;
  }
  else if (precision > 16)
  {
    precision = 16;
  }

  // Use absolute value locally
  double localValue = fabs(value);
  double localFraction = (localValue - floor(localValue)) +(5. * pow(10.0, -precision-1));
  if (localFraction >= 1)
  {
    localValue += 1.0;
    localFraction -= 1.0;
  }
  localFraction *= pow(10.0, precision);

  if (value < 0)
  {
    number += wxString(_T("-"));
  }

  number += wxString::Format(_T("%.0lf"), floor(localValue));

  // generate fraction, padding with zero if necessary.
  if (precision > 0)
  {
    number += wxString(_T("."));
    wxString fraction = wxString::Format(_T("%.0lf"), floor(localFraction));
    if (fraction.Length() < ((size_t) precision))
    {
      number += wxString(_T('0'), precision-fraction.Length());
    }
    number += fraction;
  }

  return number;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index