Precision issue for ceil function

An issue that caused me much grief during this contest and I didn’t realize until it had ended was that floating point precision would be an issue when using the ceil function.

See this for proof :

Putting it out there in case anyone else has faced a similar issue and not realized why their apparently faultless code wasn’t being accepted.

If you only need to calculate ceil of an integer division, I would recommend this.

Bro you have just used integer division . You need to typecast a to double.

1 Like

And 2nd thing even if you typecast you will get WA, it’s because the precision of double is upto 15 decimal places. So if you divide it for this number you should get a number which requires more than 15 digits after decimal. That’s why it just ignores remaining digits and upto 15 digit precision it finds 1.0 as answer, and after taking ceil of this value you will get 1.0 instead of 2.0

1 Like

That is precisely what I highlighted.