Блог пользователя Chef_Ka_Baap

Автор Chef_Ka_Baap, история, 5 лет назад, По-английски

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

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

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