Chef_Ka_Baap's blog

By Chef_Ka_Baap, history, 5 years ago, In English

ceil((double)x/n); x <= 10^12 and n <10^6; can anyone provide a test case or something I got hacked many times but was unable to find a mistake

  • Vote: I like it
  • -3
  • Vote: I do not like it

| Write comment?
»
5 years ago, hide # |
 
Vote: I like it +15 Vote: I do not like it

I can give you a reason why it can be wrong: because of how doubles are stored (IEEE 754), they might not be accurate, and that can lead to inaccurate result

if you want ceil, then use (x + n - 1) / n