I have a function returning 8 for double return type and 7 for long return type. Am not posting the function since its someway related to the ongoing contest. Can anyone pls tell me why it happens so?
Its like
double f(){return y;}
long x=f();
cout<<x<<" "<<f();
It is due to precision issues as the inbuilt function is rounding up the value of some test cases and rounding down the others, i wasted like 3 days on the same thing.
I think your question and comments are leaking TOO much information during the competition. Thousands of people here are still facing the same issue. Please wait till Monday.
you should use printf() and set precision to be .20f then you can see that the true value was 7.99999999xxxx something like this. but because you are not printing double output to that pecision it is getting rounded up to 8. but long still will take integral part part of that so it is giving 7 still. I hope this would help.