How to set precision 1e-7 or better?

Back to General discussions forum

AntonG     2015-05-04 10:17:00

I got stuck with tasks that demand to set precision 1e-7 or better. I've tried various approaches: using BigDecimal, printf, and ordinary float dividing. I would like to get at least a subtle inkling how to solve this problem. Thanks for advance.

Rodion (admin)     2015-05-04 11:24:22
User avatar

Hi! Thanks for your question (though I'm not sure which exactly problem do you mean)

It is not about "setting" precision. You only need to ensure that:

  • when you perform calculations, intermediate operations do not loose precision too much;
  • when you output the result, you print enough digits after decimal point.

For example very simple way to spoil precision is to use float instead of double, or round some intermediate results etc.

AntonG     2015-05-04 14:48:53

Thanks for your prompt response. It was kinda dummy question. With your help I managed to sort it out. :)

Please login and solve 5 problems to be able to post at forum