In my program I need to always get closest integer value greater than the argument. For that I'm using C ceil()
function.
Problem is it always returns numbers I'm not expecting.
E.g.
double num = 1 / 25.0; // num is correctly 0.04(some 0s)1
ceil(num); // ceil returns 1018
Earlier in my program I'm calling srand(time(NULL))
, so I thought maybe it has something to do with it and I commented it out, but it didn't help.
It also returns 1018 when I call the function like this ceil(0.040000001)
.
It has this weird behavior even when I call the function with arguments from the documentation.
Example program
//#include <stdio.h>
//#include <stdlib.h>
int main() {
//double var = 1 / 25.0;
double num1 = ceil(1.6); // returns 1023
return 0;
}