is no ok for wxPdfDocument::Double2String line 3805

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
JPlaroche
Earned some good credits
Earned some good credits
Posts: 131
Joined: Fri Dec 09, 2005 4:58 pm
Contact:

is no ok for wxPdfDocument::Double2String line 3805

Postby JPlaroche » Fri Jan 13, 2006 11:17 pm

// Double convert wxString: value to convert
// decimals: number of decimals

wxString DblToStr(double value, int decimal=0 )
{
if (decimal < 0 ) decimal = 0;
else if (decimal > 16 ) decimal = 16;

double d_int, d_fract;
d_fract = modf(value , &d_int);

wxString s_int, s_fract;
// recuperation decimal
wxString buf =_T("%#." + wxString::Format("%d",decimal)+"f");
s_fract = wxString::Format(buf, d_fract);
//entier
if (s_fract[0] == '1') d_int ++;
s_int = wxString::Format("%.1f", d_int);
s_int.RemoveLast(2);
s_fract.Remove(0, 2); // remove "0."

if (decimal >0 ) return s_int + '.' + s_fract;
else return s_int ;
}


j'ai teste avec 1.9999 1.99996 et precision(4) regard
apprendre et developper en C++ des sub routine interfac� HIM et BD pour validation acquis
Jean-Pierre

project define DB descripteur idem IBM400
http://www.ombrebleu.com/wxsrc/src/

lowjoel
Moderator
Moderator
Posts: 1511
Joined: Sun Jun 19, 2005 11:37 am
Location: Singapore
Contact:

Postby lowjoel » Fri Jan 13, 2006 11:21 pm



Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 1 guest