Advertisement
StormWingDelta

CheckingIfWholeNumber

Dec 28th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. bool IsWholeNumber(int TestNum, int DividedBy)
  2. {
  3.     int EndResult = 0, Quotient = 0;
  4.     Quotient = TestNum / DividedBy;
  5.     EndResult = Quotient * DividedBy;
  6.  
  7.     if(EndResult == TestNum)
  8.     {
  9.         return true;
  10.     }
  11.     else
  12.     {
  13.         return false;
  14.     }
  15.  
  16. }
  17. bool IsWholeNumberFloat(float TestNum, float DividedBy)
  18. {
  19.     float Quotient = 0;
  20.     int EndResult = 0;
  21.     Quotient = TestNum / DividedBy;
  22.     EndResult = ( ( (int)Quotient ) * ( (int)DividedBy ) );
  23.  
  24.     if(EndResult == ((int)TestNum))
  25.     {
  26.         return true;
  27.     }
  28.     else
  29.     {
  30.         return false;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement