Can't understand the meaning of absolute or relative error

in many problems, i have seen the following line in the problem statement
Your answer is considered correct if its absolute or relative error does not exceed 10−6. Formally, let your answer be X, and the jury's answer be Y. Your answer is accepted if and only if |X−Y|max(1,|Y|)≤10−6.
can someone tell me what does it means and what changes should i make to my output answer for getting a correct answer

1 Like
1 Like

Hey @abhinav_700
Thanks for sharing your doubt.

Generally, this occurs in the case when the output of code is in decimal numbers.
In the case of decimal numbers, the number of digits after the decimal point may not be fixed.
If the problem asks to print an answer such that absolute error less than 10^{-6} then your output must be correct up to 6 decimal places.

you can use the highest precision (e.g. double) for your calculations.