Sep 24, 2001 #1 PaolaS Programmer Aug 23, 2001 8 ES How can I round a double number? Ex., double x = 3.124578 Result 3.1246
Sep 25, 2001 1 #2 IonelBurtan Programmer May 25, 2001 601 RO One method would be: #include <math.h> int decimal, sign; double dTest=1.234567; const int nDecimals=3; dTest=atof(_fcvt(dTest, nDecimals,&decimal, &sign))/pow(10,nDecimals); But, I am sure there must be another simpler one... HTH, s-) Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness... http://www20.brinkster.com/ionelb Upvote 0 Downvote
One method would be: #include <math.h> int decimal, sign; double dTest=1.234567; const int nDecimals=3; dTest=atof(_fcvt(dTest, nDecimals,&decimal, &sign))/pow(10,nDecimals); But, I am sure there must be another simpler one... HTH, s-) Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness... http://www20.brinkster.com/ionelb