# flops

• 05-04-2002
krappykoder
flops
i was wondering how when my program outputs a deciaml i could round up the nuber like 3.78 to 4

its probably very simlpe but im a n00b
• 05-04-2002
Dual-Catfish
#include <math.h>

double four = ceil(3.78);
• 05-04-2002
krappykoder
i think i understand that
but what does ceil mean is it a var
• 05-04-2002
Dual-Catfish
double ceil(double x); As defined in math.h, ceil is a function which returns the smallest integral value not less than x.
• 05-04-2002
krappykoder
im must be really thick (im sorry)
i have an output lets say this

double number1 = 3.78;

cout<<number;
it will output 3.78 right
can i have that code so it will make number rounded up to 4
if atall possible
i really apecialte ure help
• 05-04-2002
MrWizard
There are multiple ways to do it. You could write your own rounding function if you so desired. The way to do it with ceiling is as follows...
Code:

```#include <iostream> using namespace std; #include <math.h> int main( void ) {     double number1 = 3.78;         // This outputs 3.78     cout << "Original number is " << number1 << endl;       number1 = ceil( number1 );     // This outputs 4.00 or something like it     cout << "New rounded number is " << number1 << endl;     return( 0 ); }```