[ create a new paste ] login | about

Link: http://codepad.org/IM5XvEBr    [ raw code | output | fork ]

C++, pasted on Sep 7:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int mround(double d) 
{
  return (int)floor(d + 0.5);
}

int main()
{
  cout << mround(3.8) << endl;
  cout << mround(-3.8) << endl;;
  cout << mround(3.3) << endl;;
  cout << mround(-3.3) << endl;;
  cout << mround(-3.5) << endl;;
  cout << mround(3.5) << endl;; 
  return 0; 
}


Output:
1
2
3
4
5
6
4
-4
3
-3
-3
4


Create a new paste based on this one


Comments: