having trouble with a persentage

how do I round up to a whole number?
Just add .5 then cast the double to an int.
example:

1
2
3
4
5
6
7
8
9
10
11
12

double number ;
double x = .5;
cin>>number;
if(number<0)
   x = -.5;


int rounded = static_cast<int>(number+x);

cout<<rounded<<endl;
Last edited on
Thanks that worked perfectly ;*D
Topic archived. No new replies allowed.