Posted: Wed Feb 27, 2002 6:37 pm
hi, all:
I include <math.h> and use the "rint" function. Its return type is double. My code is just like "int = (int)rint(double)." It can work correctly on my machine. But I don't know whether the online judge system can work or not. I have an experience that in a Wrong Answer program I use "int = (int)rint(double)", but when I write the "rint" function by myself and I got Accepted. If anyone got the same trouble with me? Or can anybody share your experience to get the integer that is nearest to a double type variable. I hate the floating point error ><... Thanks Anyway!! ^^
I include <math.h> and use the "rint" function. Its return type is double. My code is just like "int = (int)rint(double)." It can work correctly on my machine. But I don't know whether the online judge system can work or not. I have an experience that in a Wrong Answer program I use "int = (int)rint(double)", but when I write the "rint" function by myself and I got Accepted. If anyone got the same trouble with me? Or can anybody share your experience to get the integer that is nearest to a double type variable. I hate the floating point error ><... Thanks Anyway!! ^^