I've learned that we can round up and down a float number by using Ceil and floor function. But, is this function still able to work if I the number I want to round up (or down) is zero?
I have wrote my codes, but somehow it didn't give the right answer if the number is zero. My simple code looks like this:
The resut is like this:
"The nearest integer from 0.000 is 1.000"
And the same answer happen if I change Ceil to floor.
Did I miss something?
Thank you for your time.
I have wrote my codes, but somehow it didn't give the right answer if the number is zero. My simple code looks like this:
Code:
#include <math.h> int main(){ printf("The nearest integer from %f is %f\n", 0,ceil(0) ); }
"The nearest integer from 0.000 is 1.000"
And the same answer happen if I change Ceil to floor.
Did I miss something?
Thank you for your time.
Comment