TranThuyLuc's blog

By TranThuyLuc, 8 years ago, In English

In many contest problems in Codeforces where the results require float point number, there is often something like this:

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

However, the normal way to check whether two float point numbers are equal is something like this:

const double EPS = 1e-9;

bool isEqual(double x, double y){
    return abs(x - y) < EPS;
}

Is the way Codeforces use more precise? Should I use this way for comparing float point numbers instead of the normal way?

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it