Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. TEST_METHOD(CalculationsRoundTests)
  2. {
  3. int result = Calculations::Round(1.0);
  4. Assert::AreEqual(1, result);
  5. }
  6.  
  7. #ifdef EXPORT_TEST_FUNCTIONS
  8. #define MY_CALCULATIONS_EXPORT __declspec(dllexport)
  9. #else
  10. #define MY_CALCULATIONS_EXPORT
  11. #endif
  12. ...
  13. class CALCULATIONS_EXPORT Calculations {
  14. ...
  15. public:
  16. static int Round(const double& x);
  17.  
  18. int Calculations::Round(const double& x)
  19. {
  20. int temp;
  21. if (floor(x) + 0.5 > x)
  22. temp = floor(x);
  23. else
  24. temp = ceil(x);
  25.  
  26. return int(temp);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement