Arithmetic: The Ceiling of a Number 

Introduction 
Consider a floating number such as 12.155. As you can see, this number is between integer 12 and integer 13 In the same way, consider a number such as –24.06. As this number is negative, it is between –24 and –25, with –24 being greater. In arithmetic, the ceiling of a number is the closest integer that is greater or higher than the number considered. In the first case, the ceiling of 12.155 is 13 because 13 is the closest integer greater than or equal to 12.155. The ceiling of –24.06 is –24.

// #include <iostream> using namespace std; #pragma hdrstop // #pragma argsusedint main(int argc, char* argv[]) { double Value1 = 155.55; double Value2 = 24.06; cout << "The ceiling of " << Value1 << " is " << ceil(Value1) << endl; cout << "The ceiling of " << Value2 << " is " << ceil(Value2) << endl; cout << "\nPress any key to continue..."; getchar(); return 0; } // This would produce: The ceiling of 24.06 is 24 Press any key to continue...
// #include <iostream.h> #include <math.hpp> #pragma hdrstop // #pragma argsused int main(int argc, char* argv[]) { Extended Value1 = 312.44; Extended Value2 = 4002.35; cout << "The ceiling of " << Value1 << " is" << Ceil(Value1) << endl; cout << "The ceiling of " << Value2 << " is" << Ceil(Value2); cout << "\n\nPress any key to continue..."; getchar(); return 0; } // This would produce: The ceiling of 312.44 is 313 The ceiling of 4002.35 is 4002 Press any key to continue...

Home  Copyright © 20042015 FunctionX, Inc.  