|
Yes, you are perfectly right
I forgot that the rounding is always rounded-down.
|
|
|
|
|
This is another way to do that.
I did it with VC++ 6.0 to be used in my project. The return value is a string to be shown in the GUI, but you can easily adapt it just for numbers.
CString CMyDoc::CutAndRoundStringToNDecimals (double dValue, const int nDec)
{ double dTemp = 0, dFract = 0, dInt = 0, dRes = 0;
int nCount = 0;
CString cLetter = "";
dTemp = dValue*pow(10,nDec);
dFract = modf (dTemp, &dInt);
if (dFract >= 0.5)
dInt++;
dRes = dInt/pow(10,nDec);
CString szResult;
szResult.Format ("%s%f", szResult, dRes);
int nLarge = szResult.GetLength ();
for (int i = 0; i < nLarge; i++)
{ nCount++;
CString cLetter = szResult.GetAt (i);
if (cLetter == ".")
{ nCount += nDec;
break;
}
}
LPTSTR pStr = szResult.GetBufferSetLength (nCount);
szResult.ReleaseBuffer ();
return szResult;
}
Hope it helps
I forgot to say that math.h has to be included to use pow () and modf()
-- modified at 11:41 Wednesday 26th September, 2007
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hello,
i have come across with the int version of this function somewhere and changed to double in order to avoid precision problems for big and small values. You may use the int version if it fits your requirement.
double roundExt(double Num, double Seed)
{
// get rational factor
double fac = Num / Seed;
// get natural factor
fac = (fac < 0) ? (ceil(fac - 0.5)) : (floor(fac + 0.5));
// fac = (fac < 0) ? static_cast<int>(fac-0.5) : static_cast<int>(fac+0.5);
// return multiple
return fac * Seed;
}
roundExt(0.009,0.01); is the usage.
Hope this helps.
Bekir.
|
|
|
|
|
Yes , it working fine.
Thanks to all.
|
|
|
|
|
dear friends,
if i open link of rediffmail.com can i post my user ID (which i'll hard code in my VC++ application) directly on rediffmail window in User Id edit box??
is it possible? if yes can anybody help me out to do the same??
Megha
|
|
|
|
|
Do you want to fill out some elements on the a page?
|
|
|
|
|
yes for example Username on tht particular page
|
|
|
|
|
Naveen.R's answer exactly answer to your question.
|
|
|
|
|
|
Dear all,
I need msgrua.h and msgruaid.h files for my MSN Messanger plugins.
so can any body help me out for this.
please let me know how to download these files.
Thank you
Rahul Vaishnav
|
|
|
|
|
have you ever googled a bit ?
the first link i found when searching for msgrua.h is this[^]...
|
|
|
|
|
Thank you very much toxcct...
|
|
|
|
|
Hi,
how to write code for uninstallerff in vc++?
|
|
|
|
|
If I remember true some days ago you asked about uninstallerff I asked can you more explain about it but you didnt answer to me today you asked how to wrote code for it?
|
|
|
|
|
hi i developed a d3d application that loads 3d model. now i have to open it in browser. im new to this activex concept and d3d. how to create ocx for d3d. is there any tutorial. i browsed thro' but i cant i find any tutorial. pls help me its very urgent
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
deeps_cute wrote: pls help me its very urgent
Very urgent is somewhat subjective. Could you please rate the urgency on a scale of 1 to 10 where 1 is "I couldnt care less" and 10 is "if I dont find a toilet it's going to be messy"
|
|
|
|
|
"PeePee, Daddy, PeePee!"
Thats urgency! Toilet NOW, not in a minute or so.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
when i execute my MFC exe file on a machine not installed with Visual studio, i get an error saying, "coudnot find MFC42D.DLL, try reinstalling application and run again". i m not able to resolve this, can anybody please help???
rishi
|
|
|
|
|
it seems your program needs to this dll not its not on other system.you can use of depends tools for see dlls that your program needs to them.
|
|
|
|
|
Try static linking of MFC library. It is available in Project Settings
- NS -
|
|
|
|
|
i tried that but not got solution, still facing the same problem....
|
|
|
|
|
Are you using Release configuration?
- NS -
|
|
|
|
|
can you please elaborate what do you mean by release configuration???
and also if you can guide me in how to incorporate MS Office package file into my API
thanks
|
|
|
|
|
rishimohan wrote: can you please elaborate what do you mean by release configuration???
There will be two build configuration by default. Debug and Release. You can change it through Build -> Set Active Project Configuration...
rishimohan wrote: and also if you can guide me in how to incorporate MS Office package file into my API
Sorry, not so sure...
- NS -
|
|
|
|
|
THANKS A TON.... it worked....
|
|
|
|