lazy_guy_104's blog

By lazy_guy_104, history, 18 months ago, In English

Hello everyone, I have a doubt regarding precision error problems. For example I wrote a code like here.

Initially the numbers I am multiplying are 2, 10, 10, 10 i.e product should be 2000 but what I get is 1999.

I usually see people use some small value like EPS (10^(-6) or 10^(-10)) in their code. Even while comparing double they do it like abs(a-b)<=EPS, then equal else not. They do not do directly like a!=b.

Please someone explain the above observations and how to effectively take care of it in competitions. Many a times, after passing pretest we fail system tests due to precision errors. What value of EPS (epsilon) do you set or decide from the problem constraints. Please discuss your approach.

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

»
18 months ago, # |
  Vote: I like it +4 Vote: I do not like it

Could you share your code?