Click here to Skip to main content
15,916,030 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Rounding double value Pin
Stephen Hewitt25-Sep-07 21:17
Stephen Hewitt25-Sep-07 21:17 
GeneralRe: Rounding double value Pin
Nelek25-Sep-07 21:54
protectorNelek25-Sep-07 21:54 
AnswerRe: Rounding double value Pin
Cedric Moonen25-Sep-07 20:55
Cedric Moonen25-Sep-07 20:55 
GeneralRe: Rounding double value Pin
KASR125-Sep-07 21:03
KASR125-Sep-07 21:03 
GeneralRe: Rounding double value Pin
Nishad S25-Sep-07 21:09
Nishad S25-Sep-07 21:09 
GeneralRe: Rounding double value Pin
Cedric Moonen25-Sep-07 21:13
Cedric Moonen25-Sep-07 21:13 
AnswerRe: Rounding double value [modified] Pin
Nelek25-Sep-07 21:51
protectorNelek25-Sep-07 21:51 
AnswerRe: Rounding double value Pin
beko25-Sep-07 23:57
beko25-Sep-07 23:57 
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.
GeneralRe: Rounding double value Pin
KASR126-Sep-07 1:15
KASR126-Sep-07 1:15 
QuestionCan we post data on web site through VC++ application? Pin
megha_gharote25-Sep-07 20:42
megha_gharote25-Sep-07 20:42 
QuestionRe: Can we post data on web site through VC++ application? Pin
Hamid_RT25-Sep-07 21:02
Hamid_RT25-Sep-07 21:02 
AnswerRe: Can we post data on web site through VC++ application? Pin
megha_gharote25-Sep-07 21:04
megha_gharote25-Sep-07 21:04 
GeneralRe: Can we post data on web site through VC++ application? Pin
Hamid_RT25-Sep-07 21:25
Hamid_RT25-Sep-07 21:25 
AnswerRe: Can we post data on web site through VC++ application? Pin
Naveen25-Sep-07 21:18
Naveen25-Sep-07 21:18 
QuestionNeed msgrua.h and msgruaid.h files Pin
Rahul Vaishnav25-Sep-07 20:34
Rahul Vaishnav25-Sep-07 20:34 
AnswerRe: Need msgrua.h and msgruaid.h files Pin
toxcct25-Sep-07 21:05
toxcct25-Sep-07 21:05 
GeneralRe: Need msgrua.h and msgruaid.h files Pin
Rahul Vaishnav26-Sep-07 0:00
Rahul Vaishnav26-Sep-07 0:00 
QuestionUninstaller Pin
yadahav25-Sep-07 19:39
yadahav25-Sep-07 19:39 
AnswerRe: Uninstaller Pin
Hamid_RT25-Sep-07 20:25
Hamid_RT25-Sep-07 20:25 
QuestionActivex mfc - urgent pls Pin
deeps_cute25-Sep-07 18:37
deeps_cute25-Sep-07 18:37 
AnswerRe: Activex mfc - urgent pls Pin
User 58385225-Sep-07 20:04
User 58385225-Sep-07 20:04 
GeneralRe: Activex mfc - urgent pls Pin
jhwurmbach26-Sep-07 1:54
jhwurmbach26-Sep-07 1:54 
QuestionMFC42.DLL Pin
rishimohan25-Sep-07 18:19
rishimohan25-Sep-07 18:19 
AnswerRe: MFC42.DLL Pin
Hamid_RT25-Sep-07 19:43
Hamid_RT25-Sep-07 19:43 
AnswerRe: MFC42.DLL Pin
Nishad S25-Sep-07 19:49
Nishad S25-Sep-07 19:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.