### nitishp05's blog

By nitishp05, history, 6 weeks ago, Hey,

I need help in someone checking my solution to 1720A - Burenka Plays with Fractions #815 Div2, Problem A. 168812095 The number to multiply lower fraction is (higher_fraction/lower_fraction). Now to check if this number is integer or not, I used int(num) == num logic. If its equal num is int, else float. accordingly the number of claps.

Please let me know what i'm missing here.

Thanks Comments (5)
 » Computations on floating point numbers are not that exact.
•  » » Understood, thanks !
 » To compare a/b and c/d the best way is comparing a*d and c*b
 » You need to use abs(a — b) < eps, not a == b to compare floats. Underflow can happen in this line: to_multiply = max(frac1, frac2)/minfrac if frac1 = 1e9 (a = 1e9, b = 1) and frac2 = 1e-9 (c = 1, d = 1e9), then the result will be really close to zero (1e-18), so it might get rounded down to zero.Pretty sure it's mainly case 2 as I got same problem during contest (168814722 fails, but 168833377 works).
•  » » Got it ! Thanks a lot !!