This is a samll program
main()
{
double a = 0.01;
doubel b = 0.01;
int i;
i = a/b;
printf ("%d", i);
}
When I print out i, it prints 0 instead of 1. What I suspect is since its a double / double division, there might be a precision problem. How do I conver the output of the division to an integer??? I want i to be declared an integer.
The precision problem might give out an i value of 0.99988 or something like that.
Thanks
main()
{
double a = 0.01;
doubel b = 0.01;
int i;
i = a/b;
printf ("%d", i);
}
When I print out i, it prints 0 instead of 1. What I suspect is since its a double / double division, there might be a precision problem. How do I conver the output of the division to an integer??? I want i to be declared an integer.
The precision problem might give out an i value of 0.99988 or something like that.
Thanks