Convert double to string (non-cstring)?
char str[10];
double num = 1.42463;
sprintf(str, "%.2f", num);
Example:
double dValidatedPercentageValue = 0;
dValidatedPercentageValue = RoundADouble(dValue);
char str[10];
sprintf(str, "%.2f", dValidatedPercentageValue);
pGrid->PutTextMatrix(Row, Col, _bstr_t(str));
Example:
Function to round of for 2 Decimal Precision:
double Matrix::RoundADouble(double x)
{
double f, xi, xf;
xf = modf(x,&xi);
f = floor(xf*100+0.5)/100.0;
return xi + f;
}
char str[10];
double num = 1.42463;
sprintf(str, "%.2f", num);
Example:
double dValidatedPercentageValue = 0;
dValidatedPercentageValue = RoundADouble(dValue);
char str[10];
sprintf(str, "%.2f", dValidatedPercentageValue);
pGrid->PutTextMatrix(Row, Col, _bstr_t(str));
Example:
Function to round of for 2 Decimal Precision:
double Matrix::RoundADouble(double x)
{
double f, xi, xf;
xf = modf(x,&xi);
f = floor(xf*100+0.5)/100.0;
return xi + f;
}
No comments:
Post a Comment