Wojtek wrote:
Hello
What am i supposed to do to be able to use RoundTo function?
Thanx
Maybe there is a more efficient method, but here is the code i use:
#include<iostream>
#include <cmath>
using std::cout;
using std::endl;
using std::pow;
double round(double number, int digits){
int mul = (int)pow((double)10,(double)digits);
number*=mul;
if(number>0)
number+=0.5;
else
number-=0.5;
number=static_cast<int>(number);
number/=mul;
return number;
}
main () {
double a=4.34678,b;
b=round(a,3);
cout << a << ";"<<b<< endl;
a=-542.6715;
b=round(a,3);
cout << a << ";"<<b<< endl;
}
regards marbac