All the code I saw use long to calculate. Why don't you use double and get a double fraction right away and process that?
a double number holds only 16 valid digits, whereas in our problem, the decimal part can be arbitrarily long. Therefore, you can't rely on double-precision division to give you the accurate solution.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.